25 |
} |
} |
26 |
|
|
27 |
sub getWhere($) { |
sub getWhere($) { |
28 |
my ($param) = @_; |
my ($param) = @_; |
29 |
my $retSQL = ""; |
my @conditions; |
|
my @conditions = (); |
|
|
my $cond; |
|
30 |
|
|
31 |
|
sub mk_iso_date($$) { |
32 |
|
my ($name,$suffix) = @_; |
|
|
|
|
if ( defined( $param->{'search_backup_day_from'} ) && $param->{'search_backup_day_from'} ne "") { |
|
|
push( @conditions, |
|
|
' strftime("%d", datetime(backups.date, "unixepoch","localtime")) >= "' |
|
|
. $param->{'search_backup_day_from'} ."\""); |
|
|
} |
|
|
if ( defined( $param->{'search_backup_day_to'} ) && $param->{'search_backup_day_to'} ne "") { |
|
|
push( @conditions, |
|
|
' strftime("%d", datetime(backups.date, "unixepoch","localtime")) <= "' |
|
|
. $param->{'search_backup_day_from'} ."\""); |
|
|
} |
|
|
if ( defined( $param->{'search_backup_month_from'} ) && $param->{'search_backup_month_from'} ne "") { |
|
|
push( @conditions, |
|
|
' strftime("%m", datetime(backups.date, "unixepoch","localtime")) >= "' |
|
|
. $param->{'search_backup_month_from'} ."\""); |
|
|
} |
|
|
if ( defined( $param->{'search_backup_month_to'} ) && $param->{'search_backup_month_to'} ne "") { |
|
|
push( @conditions, |
|
|
' strftime("%m", datetime(backups.date, "unixepoch","localtime")) <= "' |
|
|
. $param->{'search_backup_month_to'} ."\""); |
|
|
} |
|
|
if ( defined( $param->{'search_backup_year_from'} ) && $param->{'search_backup_year_from'} ne "") { |
|
|
push( @conditions, |
|
|
' strftime("%Y", datetime(backups.date, "unixepoch","localtime")) >= "' |
|
|
. $param->{'search_backup_year_from'} ."\""); |
|
|
} |
|
|
if ( defined( $param->{'search_backup_year_to'} ) && $param->{'search_backup_year_to'} ne "") { |
|
|
push( @conditions, |
|
|
' strftime("%Y", datetime(backups.date, "unixepoch","localtime")) <= "' |
|
|
. $param->{'search_backup_year_to'} ."\""); |
|
|
} |
|
33 |
|
|
34 |
if ( defined( $param->{'search_day_from'} ) && $param->{'search_day_from'} ne "" ) { |
my $yyyy = $param->{ $name . '_year_' . $suffix} || return; |
35 |
push( @conditions, |
my $mm .= $param->{ $name . '_month_' . $suffix} || |
36 |
' strftime("%d", datetime(files.date, "unixepoch","localtime")) >= "' |
( $suffix eq 'from' ? 1 : 12); |
37 |
. $param->{'search_day_from'} ."\""); |
my $dd .= $param->{ $name . '_day_' . $suffix} || |
38 |
} |
( $suffix eq 'from' ? 1 : 31); |
39 |
if ( defined( $param->{'search_month_from'} ) && $param->{'search_month_from'} ne "") { |
return sprintf("%04d-%02d-%02d", $yyyy, $mm, $dd); |
40 |
push( @conditions, |
} |
|
' strftime("%m", datetime(files.date, "unixepoch","localtime")) >= "' |
|
|
. $param->{'search_month_from'} ."\""); |
|
|
} |
|
|
if ( defined( $param->{'search_year_from'} ) && $param->{'search_year_from'} ne "") { |
|
|
push( @conditions, |
|
|
' strftime("%Y", datetime(files.date, "unixepoch","localtime")) >= "' |
|
|
. $param->{'search_year_from'} ."\""); |
|
|
} |
|
|
if ( defined( $param->{'search_day_to'} ) && $param->{'search_day_to'} ne "" ) { |
|
|
push( @conditions, |
|
|
' strftime("%d", datetime(files.date, "unixepoch","localtime")) <= "' |
|
|
. $param->{'search_day_to'} ."\""); |
|
|
} |
|
|
if ( defined( $param->{'search_month_to'} ) && $param->{'search_month_to'} ne "" ) { |
|
|
push( @conditions, |
|
|
' strftime("%m", datetime(files.date, "unixepoch","localtime")) <= "' |
|
|
. $param->{'search_month_to'} ."\"" ); |
|
|
} |
|
|
if ( defined( $param->{'search_year_to'} )&& $param->{'search_year_to'} ne "" ) { |
|
|
push( @conditions, |
|
|
' strftime("%Y", datetime(files.date, "unixepoch","localtime")) <= "' |
|
|
. $param->{'search_year_to'} ."\""); |
|
|
} |
|
41 |
|
|
42 |
if ( defined( $param->{'search_host'} ) && $param->{'search_host'} ne "") { |
my $backup_from = mk_iso_date('search_backup', 'from'); |
43 |
push( @conditions, ' backups.hostID = ' . $param->{'search_host'} ); |
push @conditions, qq{ date(backups.date, 'unixepoch','localtime') >= '$backup_from' } if ($backup_from); |
44 |
} |
my $backup_to = mk_iso_date('search_backup', 'to'); |
45 |
|
push @conditions, qq{ date(backups.date, 'unixepoch','localtime') <= '$backup_to' } if ($backup_to); |
46 |
|
|
47 |
|
my $files_from = mk_iso_date('search', 'from'); |
48 |
|
push @conditions, qq{ date(files.date, 'unixepoch','localtime') >= '$files_from' } if ($files_from); |
49 |
|
my $files_to = mk_iso_date('search', 'to'); |
50 |
|
push @conditions, qq{ date(files.date, 'unixepoch','localtime') <= '$files_to' } if ($files_to); |
51 |
|
|
52 |
if ( defined ($param->{'search_filename'}) && $param->{'search_filename'} ne "") { |
print STDERR "backup: $backup_from - $backup_to files: $files_from - $files_to cond:",join(" | ",@conditions); |
|
push (@conditions, " files.name LIKE '".$param->{'search_filename'}."%'"); |
|
|
} |
|
53 |
|
|
54 |
$retSQL = ""; |
push( @conditions, ' backups.hostID = ' . $param->{'search_host'} ) if ($param->{'search_host'}); |
|
foreach $cond(@conditions) |
|
|
{ |
|
|
if ($retSQL ne "") |
|
|
{ |
|
|
$retSQL .= " AND "; |
|
|
} |
|
|
$retSQL .= $cond; |
|
|
} |
|
55 |
|
|
56 |
|
push (@conditions, " files.name LIKE '".$param->{'search_filename'}."%'") if ($param->{'search_filename'}); |
57 |
return $retSQL; |
|
58 |
|
return ( |
59 |
|
join(" and ", @conditions), |
60 |
|
$files_from, $files_to, |
61 |
|
$backup_from, $backup_to |
62 |
|
); |
63 |
} |
} |
64 |
|
|
65 |
|
|
66 |
sub getFiles($$) |
sub getFiles($$) |
67 |
{ |
{ |
68 |
my ($where, $offset) = @_; |
my ($where, $offset) = @_; |
87 |
FROM files |
FROM files |
88 |
INNER JOIN shares ON files.shareID=shares.ID |
INNER JOIN shares ON files.shareID=shares.ID |
89 |
INNER JOIN hosts ON hosts.ID = shares.hostID |
INNER JOIN hosts ON hosts.ID = shares.hostID |
90 |
|
INNER JOIN backups ON backups.num = files.backupNum and backups.hostID = hosts.ID |
91 |
LEFT JOIN dvds ON dvds.ID = files.dvdid |
LEFT JOIN dvds ON dvds.ID = files.dvdid |
92 |
}; |
}; |
93 |
|
|
280 |
<table style="fview" width="100%"> |
<table style="fview" width="100%"> |
281 |
<tr> |
<tr> |
282 |
<td class="tableheader">Host</td> |
<td class="tableheader">Host</td> |
|
<td class="tableheader">Type</td> |
|
283 |
<td class="tableheader">Name</td> |
<td class="tableheader">Name</td> |
284 |
<td class="tableheader">backup no.</td> |
<td class="tableheader">Type</td> |
285 |
<td class="tableheader">size</td> |
<td class="tableheader">#</td> |
286 |
<td class="tableheader">date</td> |
<td class="tableheader">Size</td> |
287 |
|
<td class="tableheader">Date</td> |
288 |
<td class="tableheader">Media</td> |
<td class="tableheader">Media</td> |
289 |
</tr> |
</tr> |
290 |
}; |
}; |
298 |
} |
} |
299 |
|
|
300 |
foreach $file (@files) { |
foreach $file (@files) { |
301 |
my $ftype = "file"; |
my $typeStr = BackupPC::Attrib::fileType2Text(undef, $file->{'type'}); |
|
$ftype = "dir" if ($file->{'type'} == BPC_FTYPE_DIR); |
|
|
|
|
302 |
$retHTML .= "<tr>"; |
$retHTML .= "<tr>"; |
303 |
|
|
304 |
foreach my $v (( |
foreach my $v (( |
305 |
$file->{'hname'}, |
$file->{'hname'}, |
306 |
$ftype, |
qq{<img src="$Conf{CgiImageDirURL}/icon-$typeStr.gif" align="center"> } . hilite_html( $file->{'fpath'}, $hilite ), |
307 |
hilite_html( $file->{'fpath'}, $hilite ), |
$typeStr, |
308 |
$file->{'backupno'}, |
$file->{'backupno'}, |
309 |
$file->{'size'}, |
$file->{'size'}, |
310 |
$file->{'date'}, |
$file->{'date'}, |