4 |
use strict; |
use strict; |
5 |
use BackupPC::CGI::Lib qw(:all); |
use BackupPC::CGI::Lib qw(:all); |
6 |
use BackupPC::Attrib qw(:all); |
use BackupPC::Attrib qw(:all); |
|
use Data::Dumper; |
|
7 |
use DBI; |
use DBI; |
8 |
|
use DateTime; |
9 |
|
use vars qw(%In $MyURL); |
10 |
|
|
11 |
|
my $on_page = 100; |
12 |
|
my $pager_pages = 10; |
13 |
|
|
14 |
|
my $dsn = $Conf{SearchDSN}; |
15 |
|
my $db_user = $Conf{SearchUser} || ''; |
16 |
|
|
17 |
sub getUnits() { |
sub getUnits() { |
18 |
my @ret = (); |
my @ret = (); |
19 |
my $tmp; |
my $tmp; |
20 |
my $dbh = DBI->connect( "dbi:SQLite:dbname=${TopDir}/$Conf{SearchDB}", |
my $dbh = DBI->connect($dsn, $db_user, "", { RaiseError => 1, AutoCommit => 1 } ); |
|
"", "", { RaiseError => 1, AutoCommit => 1 } ); |
|
21 |
my $st = |
my $st = |
22 |
$dbh->prepare( |
$dbh->prepare( |
23 |
" SELECT shares.ID AS ID, shares.share AS name FROM shares;"); |
" SELECT shares.ID AS ID, shares.share AS name FROM shares;"); |
30 |
return @ret; |
return @ret; |
31 |
} |
} |
32 |
|
|
33 |
|
sub epoch_to_iso { |
34 |
|
my $t = shift || return; |
35 |
|
my $dt = DateTime->from_epoch( epoch => $t ) || return; |
36 |
|
print STDERR "$t == ",$dt->epoch,"\n"; |
37 |
|
return $dt->ymd . ' ' . $dt->hms; |
38 |
|
} |
39 |
|
|
40 |
sub getWhere($) { |
sub getWhere($) { |
41 |
my ($param) = @_; |
my ($param) = @_; |
42 |
my @conditions; |
my @conditions; |
43 |
|
|
44 |
sub mk_iso_date($$) { |
sub mk_epoch_date($$) { |
45 |
my ($name,$suffix) = @_; |
my ($name,$suffix) = @_; |
46 |
|
|
47 |
my $yyyy = $param->{ $name . '_year_' . $suffix} || return; |
my $yyyy = $param->{ $name . '_year_' . $suffix} || return; |
49 |
( $suffix eq 'from' ? 1 : 12); |
( $suffix eq 'from' ? 1 : 12); |
50 |
my $dd .= $param->{ $name . '_day_' . $suffix} || |
my $dd .= $param->{ $name . '_day_' . $suffix} || |
51 |
( $suffix eq 'from' ? 1 : 31); |
( $suffix eq 'from' ? 1 : 31); |
52 |
return sprintf("%04d-%02d-%02d", $yyyy, $mm, $dd); |
my $dt = new DateTime( |
53 |
} |
year => $yyyy, |
54 |
|
month => $mm, |
55 |
my $backup_from = mk_iso_date('search_backup', 'from'); |
day => $dd |
56 |
push @conditions, qq{ date(backups.date, 'unixepoch','localtime') >= '$backup_from' } if ($backup_from); |
); |
57 |
my $backup_to = mk_iso_date('search_backup', 'to'); |
return $dt->epoch || 'NULL'; |
58 |
push @conditions, qq{ date(backups.date, 'unixepoch','localtime') <= '$backup_to' } if ($backup_to); |
} |
59 |
|
|
60 |
my $files_from = mk_iso_date('search', 'from'); |
my $backup_from = mk_epoch_date('search_backup', 'from'); |
61 |
push @conditions, qq{ date(files.date, 'unixepoch','localtime') >= '$files_from' } if ($files_from); |
push @conditions, qq{ backups.date >= $backup_from } if ($backup_from); |
62 |
my $files_to = mk_iso_date('search', 'to'); |
my $backup_to = mk_epoch_date('search_backup', 'to'); |
63 |
push @conditions, qq{ date(files.date, 'unixepoch','localtime') <= '$files_to' } if ($files_to); |
push @conditions, qq{ backups.date <= $backup_to } if ($backup_to); |
64 |
|
|
65 |
|
my $files_from = mk_epoch_date('search', 'from'); |
66 |
|
push @conditions, qq{ files.date >= $files_from } if ($files_from); |
67 |
|
my $files_to = mk_epoch_date('search', 'to'); |
68 |
|
push @conditions, qq{ files.date <= $files_to } if ($files_to); |
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, ' backups.hostID = ' . $param->{'search_host'} ) if ($param->{'search_host'}); |
73 |
|
|
74 |
push (@conditions, " files.name LIKE '".$param->{'search_filename'}."%'") if ($param->{'search_filename'}); |
push (@conditions, " upper(files.name) LIKE upper('%".$param->{'search_filename'}."%')") if ($param->{'search_filename'}); |
75 |
|
|
76 |
return ( |
return ( |
77 |
join(" and ", @conditions), |
join(" and ", @conditions), |
81 |
} |
} |
82 |
|
|
83 |
|
|
84 |
sub getFiles($$) |
sub getFiles($$) { |
85 |
{ |
my ($where, $offset) = @_; |
86 |
my ($where, $offset) = @_; |
|
87 |
|
my $dbh = DBI->connect($dsn, $db_user, "", { RaiseError => 1, AutoCommit => 1 } ); |
88 |
|
|
89 |
my $dbh = DBI->connect( "dbi:SQLite:dbname=${TopDir}/$Conf{SearchDB}", |
my $sql_cols = qq{ |
90 |
"", "", { RaiseError => 1, AutoCommit => 1 } ); |
files.id AS fid, |
91 |
my $sql = |
hosts.name AS hname, |
92 |
q{ |
shares.name AS sname, |
93 |
SELECT files.id AS fid, |
shares.share AS sharename, |
94 |
hosts.name AS hname, |
files.backupNum AS backupNum, |
95 |
shares.name AS sname, |
files.name AS filename, |
96 |
shares.share AS sharename, |
files.path AS filepath, |
97 |
files.backupNum AS backupNum, |
shares.share||files.fullpath AS networkPath, |
98 |
files.name AS filename, |
files.date AS date, |
99 |
files.path AS filepath, |
files.type AS filetype, |
100 |
shares.share||files.fullpath AS networkPath, |
files.size AS size, |
101 |
date(files.date, 'unixepoch', 'localtime') AS date, |
dvds.name AS dvd |
102 |
files.type AS filetype, |
}; |
103 |
files.size AS size, |
|
104 |
dvds.name AS dvd |
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 |
109 |
LEFT JOIN dvds ON dvds.ID = files.dvdid |
LEFT JOIN dvds ON dvds.ID = files.dvdid |
110 |
}; |
}; |
111 |
|
|
112 |
if (defined($where) && $where ne "") |
my $sql_where; |
113 |
{ |
$sql_where = " WHERE ". $where if ($where); |
|
$sql .= " WHERE ". $where; |
|
|
} |
|
114 |
|
|
115 |
$sql .= |
my $sql_order = qq{ |
116 |
q{ |
ORDER BY files.id |
117 |
ORDER BY files.id |
LIMIT $on_page |
118 |
LIMIT 100 |
OFFSET ? |
|
OFFSET ? * 100 + 1 |
|
119 |
}; |
}; |
|
|
|
|
|
|
|
|
|
|
my $st = $dbh->prepare( |
|
|
$sql |
|
|
); |
|
|
if (!defined($offset) && $offset ne "") |
|
|
{ |
|
|
$st->bind_param(1, $offset); |
|
|
} |
|
|
else |
|
|
{ |
|
|
$st->bind_param(1,0); |
|
|
} |
|
|
$st->execute; |
|
|
|
|
|
my @ret = (); |
|
|
my $tmp; |
|
|
|
|
|
while ($tmp = $st->fetchrow_hashref()) |
|
|
{ |
|
|
push(@ret, { |
|
|
'hname' => $tmp->{'hname'}, |
|
|
'sname' => $tmp->{'sname'}, |
|
|
'sharename' => $tmp->{'sharename'}, |
|
|
'backupno' => $tmp->{'backupNum'}, |
|
|
'fname' => $tmp->{'filename'}, |
|
|
'fpath' => $tmp->{'filepath'}, |
|
|
'networkpath' => $tmp->{'networkPath'}, |
|
|
'date' => $tmp->{'date'}, |
|
|
'type' => $tmp->{'filetype'}, |
|
|
'size' => $tmp->{'size'}, |
|
|
'id' => $tmp->{'fid'}, |
|
|
'dvd' => $tmp->{'dvd'} |
|
|
} |
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
$st->finish(); |
|
|
$dbh->disconnect(); |
|
|
return @ret; |
|
|
} |
|
120 |
|
|
121 |
sub getBackupsNotBurned() |
$offset ||= 0; |
122 |
{ |
$offset = ($offset * $on_page) + 1; |
123 |
my $dbh = DBI->connect( "dbi:SQLite:dbname=${TopDir}/$Conf{SearchDB}", |
|
124 |
"", "", { RaiseError => 1, AutoCommit => 1 } ); |
my $sth = $dbh->prepare(qq{ select count(files.id) $sql_from $sql_where }); |
125 |
my $sql = q{ |
$sth->execute(); |
126 |
SELECT |
|
127 |
hosts.ID AS hostID, |
my ($results) = $sth->fetchrow_array(); |
128 |
hosts.name AS host, |
|
129 |
backups.num AS backupno, |
$sth = $dbh->prepare(qq{ select $sql_cols $sql_from $sql_where $sql_order }); |
130 |
backups.type AS type, |
$sth->execute( $offset ); |
131 |
backups.date AS date |
|
132 |
FROM backups, shares, files, hosts |
my @ret; |
133 |
WHERE |
|
134 |
backups.num = files.backupNum AND |
while (my $row = $sth->fetchrow_hashref()) { |
135 |
shares.ID = files.shareID AND |
push(@ret, { |
136 |
backups.hostID = shares.hostID AND |
'hname' => $row->{'hname'}, |
137 |
hosts.ID = backups.hostID AND |
'sname' => $row->{'sname'}, |
138 |
files.dvdid IS NULL |
'sharename' => $row->{'sharename'}, |
139 |
GROUP BY |
'backupno' => $row->{'backupnum'}, |
140 |
backups.hostID, backups.num |
'fname' => $row->{'filename'}, |
141 |
}; |
'fpath' => $row->{'filepath'}, |
142 |
my $st = $dbh -> prepare( $sql ); |
'networkpath' => $row->{'networkpath'}, |
143 |
my @ret = (); |
'date' => $row->{'date'}, |
144 |
$st -> execute(); |
'type' => $row->{'filetype'}, |
145 |
|
'size' => $row->{'size'}, |
146 |
while ( my $tmp = $st -> fetchrow_hashref() ) |
'id' => $row->{'fid'}, |
147 |
{ |
'dvd' => $row->{'dvd'} |
148 |
push(@ret, { |
}); |
149 |
'host' => $tmp->{'host'}, |
} |
150 |
'hostid' => $tmp->{'hostID'}, |
|
151 |
'backupno' => $tmp->{'backupno'}, |
$sth->finish(); |
152 |
'type' => $tmp->{'type'}, |
$dbh->disconnect(); |
153 |
'date' => $tmp->{'date'} |
return ($results, \@ret); |
154 |
|
} |
155 |
|
|
156 |
|
sub getBackupsNotBurned() { |
157 |
|
|
158 |
|
my $dbh = DBI->connect($dsn, $db_user, "", { RaiseError => 1, AutoCommit => 1 } ); |
159 |
|
my $sql = q{ |
160 |
|
SELECT |
161 |
|
hosts.ID AS hostid, |
162 |
|
min(hosts.name) AS host, |
163 |
|
backups.num AS backupno, |
164 |
|
min(backups.type) AS type, |
165 |
|
min(backups.date) AS date |
166 |
|
FROM backups, shares, files, hosts |
167 |
|
WHERE |
168 |
|
backups.num = files.backupNum AND |
169 |
|
shares.ID = files.shareID AND |
170 |
|
backups.hostID = shares.hostID AND |
171 |
|
hosts.ID = backups.hostID AND |
172 |
|
files.dvdid IS NULL |
173 |
|
GROUP BY |
174 |
|
backups.hostID, backups.num, hosts.id |
175 |
|
}; |
176 |
|
my $sth = $dbh->prepare( $sql ); |
177 |
|
my @ret; |
178 |
|
$sth->execute(); |
179 |
|
|
180 |
|
while ( my $row = $sth->fetchrow_hashref() ) { |
181 |
|
push(@ret, { |
182 |
|
'host' => $row->{'host'}, |
183 |
|
'hostid' => $row->{'hostid'}, |
184 |
|
'backupno' => $row->{'backupno'}, |
185 |
|
'type' => $row->{'type'}, |
186 |
|
'date' => $row->{'date'} |
187 |
} |
} |
188 |
); |
); |
189 |
} |
} |
190 |
|
|
191 |
return @ret; |
return @ret; |
192 |
} |
} |
193 |
|
|
194 |
sub displayBackupsGrid() |
sub displayBackupsGrid() |
195 |
{ |
{ |
196 |
my $retHTML = ""; |
my $retHTML = ""; |
197 |
my $addForm = 1; |
my $addForm = 1; |
198 |
|
|
199 |
if ($addForm) |
if ($addForm) { |
|
{ |
|
200 |
|
|
201 |
$retHTML .= <<EOF3; |
$retHTML .= <<EOF3; |
202 |
<script language="javascript" type="text/javascript"> |
<script language="javascript" type="text/javascript"> |
219 |
//--> |
//--> |
220 |
</script> |
</script> |
221 |
EOF3 |
EOF3 |
222 |
$retHTML .= q{<form name="forma" method="POST" action="}."$MyURL"."?action=burn\""; |
$retHTML .= q{<form name="forma" method="GET" action="}."$MyURL"."?action=burn\""; |
223 |
$retHTML.= q{<input type="hidden" value="burn" name="action">}; |
$retHTML.= q{<input type="hidden" value="burn" name="action">}; |
224 |
$retHTML .= q{<input type="hidden" value="results" name="search_results">}; |
$retHTML .= q{<input type="hidden" value="results" name="search_results">}; |
225 |
} |
} |
226 |
$retHTML .= "<table style=\"fview\">"; |
$retHTML .= qq{<table style="fview"><tr>}; |
227 |
$retHTML .= "<tr> "; |
|
228 |
if ($addForm) |
if ($addForm) { |
|
{ |
|
229 |
$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>"; |
230 |
} |
} |
231 |
$retHTML .= "<td class=\"tableheader\">Host</td> <td class=\"tableheader\">Backup no</td> <td class=\"tableheader\">Type</td> <td class=\"tableheader\">date</td></tr>"; |
$retHTML .= qq{<td class="tableheader">Host</td><td class="tableheader">Backup no</td><td class="tableheader">Type</td><td class="tableheader">date</td></tr>}; |
232 |
my @backups = getBackupsNotBurned(); |
|
233 |
my $backup; |
my @backups = getBackupsNotBurned(); |
234 |
|
my $backup; |
235 |
if ($addForm) |
|
236 |
{ |
if ($addForm) { |
237 |
$retHTML .= "<tr>"; |
$retHTML .= qq{<tr><td colspan=7 style="tableheader"> |
238 |
$retHTML .= "<td colspan=7 style=\"tableheader\">"; |
<input type="submit" value="Burn selected backups on medium" name="submitBurner"> |
239 |
$retHTML .= "<input type=\"submit\" value=\"Burn selected backups on medium\" name=\"submitBurner\">"; |
</td></tr>}; |
|
$retHTML .= "</td>"; |
|
|
$retHTML .= "</tr>"; |
|
|
|
|
240 |
} |
} |
241 |
foreach $backup(@backups) |
|
242 |
{ |
foreach $backup(@backups) { |
243 |
my $ftype = ""; |
|
244 |
|
my $ftype = ""; |
245 |
|
|
246 |
$retHTML .= "<tr>"; |
$retHTML .= "<tr>"; |
247 |
if ($addForm) |
if ($addForm) { |
248 |
{ |
$retHTML .= qq{<td class="fview"><input type="checkbox" name="fcb} . |
249 |
$retHTML .= "<td class=\"fview\"> <input type=\"checkbox\" name=\"fcb" |
$backup->{'hostid'}."_".$backup->{'backupno'} . |
250 |
.$backup->{'hostid'}."_".$backup->{'backupno'} |
qq{" value="} . $backup->{'hostid'}."_".$backup->{'backupno'} . |
251 |
."\" value=\"".$backup->{'hostid'}."_".$backup->{'backupno'}."\"> </td>"; |
qq{"></td>}; |
252 |
} |
} |
253 |
|
|
254 |
$retHTML .= "<td class=\"fviewborder\">" . $backup->{'host'} . "</td>"; |
$retHTML .= '<td class="fviewborder">' . $backup->{'host'} . '</td>' . |
255 |
$retHTML .= "<td class=\"fviewborder\">" . $backup->{'backupno'} . "</td>"; |
'<td class="fviewborder">' . $backup->{'backupno'} . '</td>' . |
256 |
$retHTML .= "<td class=\"fviewborder\">" . $backup->{'type'} . "</td>"; |
'<td class="fviewborder">' . $backup->{'type'} . '</td>' . |
257 |
$retHTML .= "<td class=\"fviewborder\">" . $backup->{'date'} . "<td>"; |
'<td class="fviewborder">' . epoch_to_iso( $backup->{'date'} ) . '<td>' . |
258 |
$retHTML .= "</tr>"; |
'</tr>'; |
259 |
} |
} |
260 |
$retHTML .= "</table>"; |
|
261 |
if ($addForm) |
$retHTML .= "</table>"; |
262 |
{ |
|
263 |
$retHTML .= "</form>"; |
if ($addForm) { |
264 |
} |
$retHTML .= "</form>"; |
265 |
|
} |
266 |
|
|
267 |
return $retHTML; |
return $retHTML; |
268 |
|
} |
|
|
|
|
} |
|
269 |
|
|
270 |
sub displayGrid($$$$) { |
sub displayGrid($$$$) { |
271 |
my ($where, $addForm, $offset, $hilite) = @_; |
my ($where, $addForm, $offset, $hilite) = @_; |
272 |
my $retHTML = ""; |
my $retHTML = ""; |
273 |
|
|
274 |
if ($addForm) { |
if ($addForm) { |
275 |
$retHTML .= qq{<form name="forma" method="POST" action="}.$MyURL.qq{?action=search">}; |
$retHTML .= qq{<form name="forma" method="GET" action="$MyURL">}; |
276 |
$retHTML.= qq{<input type="hidden" value="search" name="action">}; |
$retHTML.= qq{<input type="hidden" value="search" name="action">}; |
277 |
$retHTML .= qq{<input type="hidden" value="results" name="search_results">}; |
$retHTML .= qq{<input type="hidden" value="results" name="search_results">}; |
278 |
} |
} |
279 |
|
|
280 |
|
my ($results, $files) = getFiles($where, $offset); |
281 |
|
|
282 |
|
my ($from, $to) = (($offset * $on_page) + 1, ($offset * $on_page) + $on_page); |
283 |
|
|
284 |
$retHTML .= qq{ |
$retHTML .= qq{ |
285 |
|
<br/>Found $results files, showing $from - $to |
286 |
<table style="fview" width="100%"> |
<table style="fview" width="100%"> |
287 |
<tr> |
<tr> |
288 |
<td class="tableheader">Host</td> |
<td class="tableheader">Share</td> |
|
<td class="tableheader">Type</td> |
|
289 |
<td class="tableheader">Name</td> |
<td class="tableheader">Name</td> |
290 |
<td class="tableheader">backup no.</td> |
<td class="tableheader">Type</td> |
291 |
<td class="tableheader">size</td> |
<td class="tableheader">#</td> |
292 |
<td class="tableheader">date</td> |
<td class="tableheader">Size</td> |
293 |
|
<td class="tableheader">Date</td> |
294 |
<td class="tableheader">Media</td> |
<td class="tableheader">Media</td> |
295 |
</tr> |
</tr> |
296 |
}; |
}; |
297 |
my @files = getFiles($where, $offset); |
|
298 |
my $file; |
my $file; |
299 |
|
|
300 |
sub hilite_html($$) { |
sub hilite_html($$) { |
303 |
return $html; |
return $html; |
304 |
} |
} |
305 |
|
|
306 |
foreach $file (@files) { |
sub restore_link($$$$$$) { |
307 |
my $ftype = "file"; |
my $type = shift; |
308 |
$ftype = "dir" if ($file->{'type'} == BPC_FTYPE_DIR); |
my $action = 'RestoreFile'; |
309 |
|
$action = 'browse' if (lc($type) eq 'dir'); |
310 |
|
return sprintf(qq{<a href="?action=%s&host=%s&num=%d&share=%s&dir=%s">%s</a>}, $action, @_); |
311 |
|
} |
312 |
|
|
313 |
|
foreach $file (@{ $files }) { |
314 |
|
my $typeStr = BackupPC::Attrib::fileType2Text(undef, $file->{'type'}); |
315 |
$retHTML .= "<tr>"; |
$retHTML .= "<tr>"; |
316 |
|
|
317 |
foreach my $v (( |
foreach my $v (( |
318 |
$file->{'hname'}, |
$file->{'sharename'}, |
319 |
$ftype, |
qq{<img src="$Conf{CgiImageDirURL}/icon-$typeStr.gif" align="center"> } . hilite_html( $file->{'fpath'}, $hilite ), |
320 |
hilite_html( $file->{'fpath'}, $hilite ), |
$typeStr, |
321 |
$file->{'backupno'}, |
restore_link( $typeStr, $file->{'hname'}, $file->{'backupno'}, $file->{'sname'}, $file->{'fpath'}, $file->{'backupno'} ), |
322 |
$file->{'size'}, |
$file->{'size'}, |
323 |
$file->{'date'}, |
epoch_to_iso( $file->{'date'} ), |
324 |
$file->{'dvd'} |
$file->{'dvd'} |
325 |
)) { |
)) { |
326 |
$retHTML .= qq{<td class="fviewborder">$v</td>}; |
$retHTML .= qq{<td class="fviewborder">$v</td>}; |
330 |
} |
} |
331 |
$retHTML .= "</table>"; |
$retHTML .= "</table>"; |
332 |
|
|
333 |
# skip pager |
# all variables which has to be transfered |
334 |
return $retHTML; |
foreach my $n (qw/search_day_from search_month_from search_year_from search_day_to search_month_to search_year_to search_backup_day_from search_backup_month_from search_backup_year_from search_backup_day_to search_backup_month_to search_backup_year_to search_filename offset/) { |
335 |
|
$retHTML .= qq{<INPUT TYPE="hidden" NAME="$n" VALUE="$In{$n}">\n}; |
336 |
|
} |
337 |
|
|
338 |
|
my $del = ''; |
339 |
|
my $max_page = int( $results / $on_page ); |
340 |
|
my $page = 0; |
341 |
|
|
342 |
|
my $link_fmt = '<a href = "#" onclick="document.forma.offset.value=%d;document.forma.submit();">%s</a>'; |
343 |
|
|
344 |
|
$retHTML .= '<div style="text-align: center;">'; |
345 |
|
|
346 |
$retHTML .= "<INPUT TYPE=\"hidden\" VALUE=\"\" NAME=\"offset\">"; |
if ($offset > 0) { |
347 |
for (my $ii = 1; $ii <= $#files; $ii++) { |
$retHTML .= sprintf($link_fmt, $offset - 1, '<<') . ' '; |
348 |
$retHTML .= "<a href = \"#\" onclick=\"document.forma.offset.value=$ii;document.forma.submit();\">$ii</a>"; |
} |
349 |
if ($ii < $#files) { |
|
350 |
$retHTML .= " | "; |
while ($page <= $max_page) { |
351 |
|
if ($page == $offset) { |
352 |
|
$retHTML .= $del . '<b>' . ($page + 1) . '</b>'; |
353 |
|
} else { |
354 |
|
$retHTML .= $del . sprintf($link_fmt, $page, $page + 1); |
355 |
|
} |
356 |
|
|
357 |
|
if ($page < $offset - $pager_pages && $page != 0) { |
358 |
|
$retHTML .= " ... "; |
359 |
|
$page = $offset - $pager_pages; |
360 |
|
$del = ''; |
361 |
|
} elsif ($page > $offset + $pager_pages && $page != $max_page) { |
362 |
|
$retHTML .= " ... "; |
363 |
|
$page = $max_page; |
364 |
|
$del = ''; |
365 |
|
} else { |
366 |
|
$del = ' | '; |
367 |
|
$page++; |
368 |
} |
} |
369 |
} |
} |
370 |
|
|
371 |
|
if ($offset < $max_page) { |
372 |
|
$retHTML .= ' ' . sprintf($link_fmt, $offset + 1, '>>'); |
373 |
|
} |
374 |
|
|
375 |
|
$retHTML .= "</div>"; |
376 |
|
|
377 |
$retHTML .= "</form>" if ($addForm); |
$retHTML .= "</form>" if ($addForm); |
378 |
|
|
379 |
return $retHTML; |
return $retHTML; |
380 |
} |
} |
381 |
|
|