19 |
my @ret; |
my @ret; |
20 |
|
|
21 |
my $dbh = DBI->connect($dsn, $db_user, "", { RaiseError => 1, AutoCommit => 1 } ); |
my $dbh = DBI->connect($dsn, $db_user, "", { RaiseError => 1, AutoCommit => 1 } ); |
22 |
my $sth = $dbh->prepare(qq{ SELECT id, share FROM shares} ); |
my $sth = $dbh->prepare(qq{ SELECT id, share FROM shares ORDER BY share} ); |
23 |
$sth->execute(); |
$sth->execute(); |
24 |
push @ret, { 'id' => '', 'share' => '-'}; # dummy any |
push @ret, { 'id' => '', 'share' => '-'}; # dummy any |
25 |
|
|
32 |
|
|
33 |
sub epoch_to_iso { |
sub epoch_to_iso { |
34 |
my $t = shift || return; |
my $t = shift || return; |
35 |
my $dt = DateTime->from_epoch( epoch => $t ) || return; |
my $iso = BackupPC::Lib::timeStamp($t); |
36 |
print STDERR "BUG: $t != " . $dt->epoch . "\n" unless ($t == $dt->epoch); |
$iso =~ s/\s/ /g; |
37 |
return $dt->ymd . ' ' . $dt->hms; |
return $iso; |
38 |
} |
} |
39 |
|
|
40 |
sub getWhere($) { |
sub getWhere($) { |
69 |
|
|
70 |
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(" | ",@conditions); |
71 |
|
|
72 |
push( @conditions, ' backups.hostID = ' . $param->{'search_host'} ) if ($param->{'search_host'}); |
push( @conditions, ' files.shareid = ' . $param->{'search_share'} ) if ($param->{'search_share'}); |
73 |
|
|
74 |
push (@conditions, " upper(files.name) LIKE upper('%".$param->{'search_filename'}."%')") if ($param->{'search_filename'}); |
push (@conditions, " upper(files.path) LIKE upper('%".$param->{'search_filename'}."%')") if ($param->{'search_filename'}); |
75 |
|
|
76 |
return ( |
return ( |
77 |
join(" and ", @conditions), |
join(" and ", @conditions), |
94 |
files.backupNum AS backupNum, |
files.backupNum AS backupNum, |
95 |
files.name AS filename, |
files.name AS filename, |
96 |
files.path AS filepath, |
files.path AS filepath, |
|
shares.share||files.fullpath AS networkPath, |
|
97 |
files.date AS date, |
files.date AS date, |
98 |
files.type AS filetype, |
files.type AS filetype, |
99 |
files.size AS size, |
files.size AS size, |
100 |
dvds.name AS dvd |
-- dvds.name AS dvd |
101 |
|
null AS dvd |
102 |
}; |
}; |
103 |
|
|
104 |
my $sql_from = qq{ |
my $sql_from = qq{ |
105 |
FROM files |
FROM files |
106 |
INNER JOIN shares ON files.shareID=shares.ID |
INNER JOIN shares ON files.shareID=shares.ID |
107 |
INNER JOIN hosts ON hosts.ID = shares.hostID |
INNER JOIN hosts ON hosts.ID = shares.hostID |
108 |
INNER JOIN backups ON backups.num = files.backupNum and backups.hostID = hosts.ID |
INNER JOIN backups ON backups.num = files.backupNum and backups.hostID = hosts.ID AND backups.shareID = shares.ID |
109 |
}; |
}; |
110 |
|
|
111 |
my $sql_dvd_from = qq{ |
my $sql_dvd_from = qq{ |
112 |
LEFT JOIN dvds ON dvds.ID = files.dvdid |
-- LEFT JOIN dvds ON dvds.ID = files.dvdid |
113 |
}; |
}; |
114 |
|
|
115 |
my $sql_where; |
my $sql_where; |
116 |
$sql_where = " WHERE ". $where if ($where); |
$sql_where = " WHERE ". $where if ($where); |
117 |
|
|
118 |
my $sql_order = qq{ |
my $sql_order = qq{ |
119 |
ORDER BY files.id |
ORDER BY files.date |
120 |
LIMIT $on_page |
LIMIT $on_page |
121 |
OFFSET ? |
OFFSET ? |
122 |
}; |
}; |
169 |
my $dbh = DBI->connect($dsn, $db_user, "", { RaiseError => 1, AutoCommit => 1 } ); |
my $dbh = DBI->connect($dsn, $db_user, "", { RaiseError => 1, AutoCommit => 1 } ); |
170 |
my $sql = q{ |
my $sql = q{ |
171 |
SELECT |
SELECT |
172 |
hosts.ID AS hostid, |
backups.hostID AS hostid, |
173 |
min(hosts.name) AS host, |
min(hosts.name) AS host, |
174 |
backups.num AS backupno, |
backups.num AS backupno, |
175 |
min(backups.type) AS type, |
min(backups.type) AS type, |
176 |
min(backups.date) AS date |
min(backups.date) AS date, |
177 |
FROM backups, shares, files, hosts |
min(backups.size) AS size |
178 |
|
FROM files |
179 |
|
INNER JOIN shares ON files.shareID=shares.ID |
180 |
|
INNER JOIN hosts ON hosts.ID = shares.hostID |
181 |
|
INNER JOIN backups ON backups.num = files.backupNum and backups.hostID = hosts.ID AND backups.shareID = shares.ID |
182 |
WHERE |
WHERE |
|
backups.num = files.backupNum AND |
|
|
shares.ID = files.shareID AND |
|
|
backups.hostID = shares.hostID AND |
|
|
hosts.ID = backups.hostID AND |
|
183 |
files.dvdid IS NULL |
files.dvdid IS NULL |
184 |
GROUP BY |
GROUP BY |
185 |
backups.hostID, backups.num, hosts.id |
backups.hostID, backups.num |
186 |
ORDER BY min(backups.date) |
ORDER BY min(backups.date) |
187 |
}; |
}; |
188 |
my $sth = $dbh->prepare( $sql ); |
my $sth = $dbh->prepare( $sql ); |
189 |
my @ret; |
my @ret; |
190 |
$sth->execute(); |
$sth->execute(); |
191 |
|
|
192 |
while ( my $row = $sth->fetchrow_hashref() ) { |
while ( my $row = $sth->fetchrow_hashref() ) { |
193 |
push(@ret, { |
$row->{'age'} = sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) ); |
194 |
'host' => $row->{'host'}, |
$row->{'size'} = sprintf("%0.2f", $row->{'size'} / 1024 / 1024); |
195 |
'hostid' => $row->{'hostid'}, |
push @ret, $row; |
|
'backupno' => $row->{'backupno'}, |
|
|
'type' => $row->{'type'}, |
|
|
'date' => $row->{'date'}, |
|
|
'age' => sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) ), |
|
|
} |
|
|
); |
|
196 |
} |
} |
197 |
|
|
198 |
return @ret; |
return @ret; |
230 |
$retHTML.= q{<input type="hidden" value="burn" name="action">}; |
$retHTML.= q{<input type="hidden" value="burn" name="action">}; |
231 |
$retHTML .= q{<input type="hidden" value="results" name="search_results">}; |
$retHTML .= q{<input type="hidden" value="results" name="search_results">}; |
232 |
} |
} |
233 |
$retHTML .= qq{<table style="fview"><tr>}; |
$retHTML .= qq{ |
234 |
|
<table style="fview" border="1" cellspacing="0" cellpadding="3"> |
235 |
|
<tr class="tableheader"> |
236 |
|
}; |
237 |
|
|
238 |
if ($addForm) { |
if ($addForm) { |
239 |
$retHTML .= "<td class=\"tableheader\"><input type=\"checkbox\" name=\"allFiles\" onClick=\"checkAll('allFiles');\"></td>"; |
$retHTML .= "<td class=\"tableheader\"><input type=\"checkbox\" name=\"allFiles\" onClick=\"checkAll('allFiles');\"></td>"; |
240 |
} |
} |
241 |
$retHTML .= qq{ |
$retHTML .= qq{ |
242 |
<td class="tableheader">Host</td> |
<td align="center">Host</td> |
243 |
<td class="tableheader">Backup no</td> |
<td align="center">Backup no</td> |
244 |
<td class="tableheader">Type</td> |
<td align="center">Type</td> |
245 |
<td class="tableheader">date</td> |
<td align="center">date</td> |
246 |
<td class="tableheader">age/days</td> |
<td align="center">age/days</td> |
247 |
|
<td align="center">size/MB</td> |
248 |
</tr> |
</tr> |
249 |
}; |
}; |
250 |
|
|
276 |
'<td class="fviewborder">' . $backup->{'type'} . '</td>' . |
'<td class="fviewborder">' . $backup->{'type'} . '</td>' . |
277 |
'<td class="fviewborder">' . epoch_to_iso( $backup->{'date'} ) . '</td>' . |
'<td class="fviewborder">' . epoch_to_iso( $backup->{'date'} ) . '</td>' . |
278 |
'<td class="fviewborder">' . $backup->{'age'} . '</td>' . |
'<td class="fviewborder">' . $backup->{'age'} . '</td>' . |
279 |
|
'<td class="fviewborder">' . $backup->{'size'} . '</td>' . |
280 |
'</tr>'; |
'</tr>'; |
281 |
} |
} |
282 |
|
|
322 |
|
|
323 |
|
|
324 |
$retHTML .= qq{ |
$retHTML .= qq{ |
325 |
<br/>Found <b>$results files</b> showing <b>$from - $to</b> (took $dur) |
<div> |
326 |
<table style="fview" width="100%"> |
Found <b>$results files</b> showing <b>$from - $to</b> (took $dur) |
327 |
<tr> |
</div> |
328 |
<td class="tableheader">Share</td> |
<table style="fview" width="100%" border="0" cellpadding="2" cellspacing="0"> |
329 |
<td class="tableheader">Name</td> |
<tr class="fviewheader"> |
330 |
<td class="tableheader">Type</td> |
<td align="center">Share</td> |
331 |
<td class="tableheader">#</td> |
<td align="center">Type and Name</td> |
332 |
<td class="tableheader">Size</td> |
<td align="center">#</td> |
333 |
<td class="tableheader">Date</td> |
<td align="center">Size</td> |
334 |
<td class="tableheader">Media</td> |
<td align="center">Date</td> |
335 |
|
<td align="center">Media</td> |
336 |
</tr> |
</tr> |
337 |
}; |
}; |
338 |
|
|
353 |
|
|
354 |
foreach $file (@{ $files }) { |
foreach $file (@{ $files }) { |
355 |
my $typeStr = BackupPC::Attrib::fileType2Text(undef, $file->{'type'}); |
my $typeStr = BackupPC::Attrib::fileType2Text(undef, $file->{'type'}); |
356 |
$retHTML .= "<tr>"; |
$retHTML .= qq{<tr class="fviewborder">}; |
357 |
|
|
358 |
foreach my $v (( |
$retHTML .= |
359 |
$file->{'sharename'}, |
qq{<td class="fviewborder" align="right">} . $file->{'sharename'} . qq{</td>} . |
360 |
qq{<img src="$Conf{CgiImageDirURL}/icon-$typeStr.gif" align="center"> } . hilite_html( $file->{'fpath'}, $hilite ), |
qq{<td class="fviewborder"><img src="$Conf{CgiImageDirURL}/icon-$typeStr.gif" alt="$typeStr" align="middle"> } . hilite_html( $file->{'fpath'}, $hilite ) . qq{</td>} . |
361 |
$typeStr, |
qq{<td class="fviewborder" align="center">} . restore_link( $typeStr, ${EscURI( $file->{'hname'} )}, $file->{'backupno'}, ${EscURI( $file->{'sname'})}, ${EscURI( $file->{'fpath'} )}, $file->{'backupno'} ) . qq{</td>} . |
362 |
restore_link( $typeStr, $file->{'hname'}, $file->{'backupno'}, $file->{'sname'}, $file->{'fpath'}, $file->{'backupno'} ), |
qq{<td class="fviewborder" align="right">} . $file->{'size'} . qq{</td>} . |
363 |
$file->{'size'}, |
qq{<td class="fviewborder">} . epoch_to_iso( $file->{'date'} ) . qq{</td>} . |
364 |
epoch_to_iso( $file->{'date'} ), |
qq{<td class="fviewborder">} . $file->{'dvd'} . qq{</td>}; |
|
$file->{'dvd'} |
|
|
)) { |
|
|
$retHTML .= qq{<td class="fviewborder">$v</td>}; |
|
|
} |
|
365 |
|
|
366 |
$retHTML .= "</tr>"; |
$retHTML .= "</tr>"; |
367 |
} |
} |