175 |
return ($results, \@ret); |
return ($results, \@ret); |
176 |
} |
} |
177 |
|
|
178 |
|
sub getHyperEstraier_url($) { |
179 |
|
my ($use_hest) = @_; |
180 |
|
|
181 |
|
return unless $use_hest; |
182 |
|
|
183 |
|
use HyperEstraier; |
184 |
|
my ($index_path, $index_node_url); |
185 |
|
|
186 |
|
if ($use_hest =~ m#^http://#) { |
187 |
|
$index_node_url = $use_hest; |
188 |
|
} else { |
189 |
|
$index_path = $TopDir . '/' . $index_path; |
190 |
|
$index_path =~ s#//#/#g; |
191 |
|
} |
192 |
|
return ($index_path, $index_node_url); |
193 |
|
} |
194 |
|
|
195 |
sub getFilesHyperEstraier($) { |
sub getFilesHyperEstraier($) { |
196 |
my ($param) = @_; |
my ($param) = @_; |
197 |
|
|
202 |
|
|
203 |
use HyperEstraier; |
use HyperEstraier; |
204 |
|
|
205 |
|
my ($index_path, $index_node_url) = getHyperEstraier_url($index_path); |
206 |
|
|
207 |
# open the database |
# open the database |
208 |
my $db = HyperEstraier::Database->new(); |
my $db; |
209 |
$db->open($index_path, $HyperEstraier::ESTDBREADER); |
if ($index_path) { |
210 |
|
$db = HyperEstraier::Database->new(); |
211 |
|
$db->open($index_path, $HyperEstraier::ESTDBREADER); |
212 |
|
} elsif ($index_node_url) { |
213 |
|
$db ||= HyperEstraier::Node->new($index_node_url); |
214 |
|
$db->set_auth('admin', 'admin'); |
215 |
|
} else { |
216 |
|
die "BUG: unimplemented"; |
217 |
|
} |
218 |
|
|
219 |
# create a search condition object |
# create a search condition object |
220 |
my $cond = HyperEstraier::Condition->new(); |
my $cond = HyperEstraier::Condition->new(); |
222 |
my $q = $param->{'search_filename'}; |
my $q = $param->{'search_filename'}; |
223 |
my $shareid = $param->{'search_share'}; |
my $shareid = $param->{'search_share'}; |
224 |
|
|
225 |
if ($q) { |
if (length($q) > 0) { |
226 |
$q =~ s/(.)/$1 /g; |
# exact match |
227 |
|
$cond->add_attr("filepath ISTRINC $q"); |
228 |
|
|
229 |
|
$q =~ s/(.)/$1 /g; |
230 |
# set the search phrase to the search condition object |
# set the search phrase to the search condition object |
231 |
$cond->set_phrase($q); |
$cond->set_phrase($q); |
232 |
} |
} |
246 |
$cond->set_order( 'date NUMA' ); |
$cond->set_order( 'date NUMA' ); |
247 |
|
|
248 |
# get the result of search |
# get the result of search |
|
my $result = $db->search($cond, 0); |
|
|
|
|
249 |
my @res; |
my @res; |
250 |
my $hits = $result->size; |
my ($result, $hits); |
251 |
|
|
252 |
|
if ($index_path) { |
253 |
|
$result = $db->search($cond, 0); |
254 |
|
$hits = $result->size; |
255 |
|
} elsif ($index_node_url) { |
256 |
|
$result = $db->search($cond, 0); |
257 |
|
$hits = $result->doc_num; |
258 |
|
} else { |
259 |
|
die "BUG: unimplemented"; |
260 |
|
} |
261 |
|
|
262 |
# for each document in result |
# for each document in result |
263 |
for my $i ($offset .. ($offset + $on_page - 1)) { |
for my $i ($offset .. ($offset + $on_page - 1)) { |
264 |
last if ($i >= $hits); |
last if ($i >= $hits); |
265 |
|
|
266 |
my $id = $result->get($i); |
my $doc; |
267 |
my $doc = $db->get_doc($id, 0); |
if ($index_path) { |
268 |
|
my $id = $result->get($i); |
269 |
|
$doc = $db->get_doc($id, 0); |
270 |
|
} elsif ($index_node_url) { |
271 |
|
$doc = $result->get_doc($i); |
272 |
|
} else { |
273 |
|
die "BUG: unimplemented"; |
274 |
|
} |
275 |
|
|
276 |
my $row; |
my $row; |
277 |
foreach my $c (qw/fid hname sname backupnum fiilename filepath date type size/) { |
foreach my $c (qw/fid hname sname backupnum fiilename filepath date type size/) { |
283 |
return ($hits, \@res); |
return ($hits, \@res); |
284 |
} |
} |
285 |
|
|
286 |
|
sub getGzipName($$$) |
287 |
|
{ |
288 |
|
my ($host, $share, $backupnum) = @_; |
289 |
|
my $ret = $Conf{GzipSchema}; |
290 |
|
|
291 |
|
$share =~ s/\//_/g; |
292 |
|
$ret =~ s/\\h/$host/ge; |
293 |
|
$ret =~ s/\\s/$share/ge; |
294 |
|
$ret =~ s/\\n/$backupnum/ge; |
295 |
|
|
296 |
|
return $ret; |
297 |
|
|
298 |
|
} |
299 |
|
|
300 |
sub getBackupsNotBurned() { |
sub getBackupsNotBurned() { |
301 |
|
|
302 |
my $dbh = get_dbh(); |
my $dbh = get_dbh(); |
304 |
SELECT |
SELECT |
305 |
backups.hostID AS hostid, |
backups.hostID AS hostid, |
306 |
min(hosts.name) AS host, |
min(hosts.name) AS host, |
307 |
|
min(shares.name) AS share, |
308 |
backups.num AS backupnum, |
backups.num AS backupnum, |
309 |
min(backups.type) AS type, |
min(backups.type) AS type, |
310 |
min(backups.date) AS date, |
min(backups.date) AS date, |
314 |
INNER JOIN hosts ON hosts.ID = shares.hostID |
INNER JOIN hosts ON hosts.ID = shares.hostID |
315 |
INNER JOIN backups ON backups.num = files.backupnum and backups.hostID = hosts.ID AND backups.shareID = shares.ID |
INNER JOIN backups ON backups.num = files.backupnum and backups.hostID = hosts.ID AND backups.shareID = shares.ID |
316 |
GROUP BY |
GROUP BY |
317 |
backups.hostID, backups.num |
backups.hostID, backups.num, backups.shareid |
318 |
ORDER BY min(backups.date) |
ORDER BY min(backups.date) |
319 |
}; |
}; |
320 |
my $sth = $dbh->prepare( $sql ); |
my $sth = $dbh->prepare( $sql ); |
324 |
while ( my $row = $sth->fetchrow_hashref() ) { |
while ( my $row = $sth->fetchrow_hashref() ) { |
325 |
$row->{'age'} = sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) ); |
$row->{'age'} = sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) ); |
326 |
$row->{'size'} = sprintf("%0.2f", $row->{'size'} / 1024 / 1024); |
$row->{'size'} = sprintf("%0.2f", $row->{'size'} / 1024 / 1024); |
327 |
|
my (undef,undef,undef,undef,undef,undef,undef,$fs_size,undef,undef,undef,undef,undef) = |
328 |
|
stat( $Conf{InstallDir}.'/'.$Conf{GzipTempDir}.'/'. |
329 |
|
getGzipName($row->{'host'}, $row->{share}, $row->{'backupnum'})); |
330 |
|
$row->{'fs_size'} = $fs_size; |
331 |
push @ret, $row; |
push @ret, $row; |
332 |
} |
} |
333 |
|
|
337 |
sub displayBackupsGrid() |
sub displayBackupsGrid() |
338 |
{ |
{ |
339 |
my $retHTML = ""; |
my $retHTML = ""; |
|
my $addForm = 1; |
|
340 |
|
|
341 |
if ($addForm) { |
$retHTML .= <<EOF3; |
|
|
|
|
$retHTML .= <<EOF3; |
|
342 |
<script language="javascript" type="text/javascript"> |
<script language="javascript" type="text/javascript"> |
343 |
<!-- |
<!-- |
344 |
|
|
359 |
//--> |
//--> |
360 |
</script> |
</script> |
361 |
EOF3 |
EOF3 |
362 |
$retHTML .= q{<form name="forma" method="GET" action="}."$MyURL"."?action=burn\""; |
$retHTML .= q{ |
363 |
$retHTML.= q{<input type="hidden" value="burn" name="action">}; |
<form name="forma" method="GET" action="$MyURL?action=burn"> |
364 |
$retHTML .= q{<input type="hidden" value="results" name="search_results">}; |
<input type="hidden" value="burn" name="action"> |
365 |
} |
<input type="hidden" value="results" name="search_results"> |
366 |
$retHTML .= qq{ |
<table style="fview" border="0" cellspacing="0" cellpadding="2"> |
|
<table style="fview" border="1" cellspacing="0" cellpadding="3"> |
|
367 |
<tr class="tableheader"> |
<tr class="tableheader"> |
368 |
}; |
<td class="tableheader"> |
369 |
|
<input type="checkbox" name="allFiles" onClick="checkAll('allFiles');"> |
370 |
if ($addForm) { |
</td> |
371 |
$retHTML .= "<td class=\"tableheader\"><input type=\"checkbox\" name=\"allFiles\" onClick=\"checkAll('allFiles');\"></td>"; |
<td align="center">Share</td> |
|
} |
|
|
$retHTML .= qq{ |
|
|
<td align="center">Host</td> |
|
372 |
<td align="center">Backup no</td> |
<td align="center">Backup no</td> |
373 |
<td align="center">Type</td> |
<td align="center">Type</td> |
374 |
<td align="center">date</td> |
<td align="center">date</td> |
375 |
<td align="center">age/days</td> |
<td align="center">age/days</td> |
376 |
<td align="center">size/MB</td> |
<td align="center">size/MB</td> |
377 |
|
<td align="center">gzip size</td> |
378 |
</tr> |
</tr> |
379 |
|
|
380 |
|
<tr><td colspan=7 style="tableheader"> |
381 |
|
<input type="submit" value="Burn selected backups on medium" name="submitBurner"> |
382 |
|
</td></tr> |
383 |
}; |
}; |
384 |
|
|
385 |
my @backups = getBackupsNotBurned(); |
my @color = (' bgcolor="#e0e0e0"', ''); |
|
my $backup; |
|
386 |
|
|
387 |
if ($addForm) { |
my $i = 0; |
388 |
$retHTML .= qq{ |
my $host = ''; |
|
<tr><td colspan=7 style="tableheader"> |
|
|
<input type="submit" value="Burn selected backups on medium" name="submitBurner"> |
|
|
</td></tr> |
|
|
}; |
|
|
} |
|
389 |
|
|
390 |
foreach $backup(@backups) { |
foreach my $backup ( getBackupsNotBurned() ) { |
391 |
|
|
392 |
|
if ($host ne $backup->{'host'}) { |
393 |
|
$i++; |
394 |
|
$host = $backup->{'host'}; |
395 |
|
} |
396 |
my $ftype = ""; |
my $ftype = ""; |
397 |
|
|
398 |
$retHTML .= "<tr>"; |
$retHTML .= "<tr" . $color[$i %2 ] . ">"; |
399 |
if ($addForm) { |
$retHTML .= '<td class="fview"><input type="checkbox" name="fcb' . |
|
$retHTML .= '<td class="fview"><input type="checkbox" name="fcb' . |
|
400 |
$backup->{'hostid'}.'_'.$backup->{'backupnum'} . |
$backup->{'hostid'}.'_'.$backup->{'backupnum'} . |
401 |
'" value="' . $backup->{'hostid'}.'_'.$backup->{'backupnum'} . |
'" value="' . $backup->{'hostid'}.'_'.$backup->{'backupnum'} . |
402 |
'"></td>'; |
'"></td>'; |
|
} |
|
403 |
|
|
404 |
$retHTML .= '<td class="fviewborder">' . $backup->{'host'} . '</td>' . |
$retHTML .= |
405 |
'<td class="fviewborder">' . $backup->{'backupnum'} . '</td>' . |
'<td align="right">' . $backup->{'host'} . ':' . $backup->{'share'} . '</td>' . |
406 |
'<td class="fviewborder">' . $backup->{'type'} . '</td>' . |
'<td align="center">' . $backup->{'backupnum'} . '</td>' . |
407 |
'<td class="fviewborder">' . epoch_to_iso( $backup->{'date'} ) . '</td>' . |
'<td align="center">' . $backup->{'type'} . '</td>' . |
408 |
'<td class="fviewborder">' . $backup->{'age'} . '</td>' . |
'<td align="center">' . epoch_to_iso( $backup->{'date'} ) . '</td>' . |
409 |
'<td class="fviewborder">' . $backup->{'size'} . '</td>' . |
'<td align="center">' . $backup->{'age'} . '</td>' . |
410 |
'</tr>'; |
'<td align="right">' . $backup->{'size'} . '</td>' . |
411 |
} |
'<td align="right">' . $backup->{'fs_size'} .'</td>' . |
412 |
|
"</tr>\n"; |
413 |
|
|
|
$retHTML .= "</table>"; |
|
414 |
|
|
|
if ($addForm) { |
|
|
$retHTML .= "</form>"; |
|
415 |
} |
} |
416 |
|
|
417 |
|
$retHTML .= "</table>"; |
418 |
|
$retHTML .= "</form>"; |
419 |
|
|
420 |
return $retHTML; |
return $retHTML; |
421 |
} |
} |
431 |
my $start_t = time(); |
my $start_t = time(); |
432 |
|
|
433 |
my ($results, $files); |
my ($results, $files); |
434 |
if ($param->{'use_hest'}) { |
if ($param->{'use_hest'} && length($hilite) > 0) { |
435 |
($results, $files) = getFilesHyperEstraier($param); |
($results, $files) = getFilesHyperEstraier($param); |
436 |
} else { |
} else { |
437 |
($results, $files) = getFiles($param); |
($results, $files) = getFiles($param); |
493 |
my $typeStr = BackupPC::Attrib::fileType2Text(undef, $file->{'type'}); |
my $typeStr = BackupPC::Attrib::fileType2Text(undef, $file->{'type'}); |
494 |
$retHTML .= qq{<tr class="fviewborder">}; |
$retHTML .= qq{<tr class="fviewborder">}; |
495 |
|
|
496 |
$retHTML .= qq{<td>$i</td>}; |
$retHTML .= qq{<td class="fviewborder">$i</td>}; |
497 |
|
|
498 |
$retHTML .= |
$retHTML .= |
499 |
qq{<td class="fviewborder" align="right">} . $file->{'hname'} . ':' . $file->{'sname'} . qq{</td>} . |
qq{<td class="fviewborder" align="right">} . $file->{'hname'} . ':' . $file->{'sname'} . qq{</td>} . |