]> git.deb.at Git - deb/packages.git/blob - cgi-bin/search_packages.pl
Move some more parameter logic to the Search.pm modul
[deb/packages.git] / cgi-bin / search_packages.pl
1 #!/usr/bin/perl -wT
2 #
3 # search_packages.pl -- CGI interface to the Packages files on packages.debian.org
4 #
5 # Copyright (C) 1998 James Treacy
6 # Copyright (C) 2000, 2001 Josip Rodin
7 # Copyright (C) 2001 Adam Heath
8 # Copyright (C) 2004 Martin Schulze
9 # Copyright (C) 2004-2006 Frank Lichtenheld
10 #
11 # use is allowed under the terms of the GNU Public License (GPL)                              
12 # see http://www.fsf.org/copyleft/gpl.html for a copy of the license
13
14 use strict;
15 use CGI qw( -oldstyle_urls );
16 use CGI::Carp qw( fatalsToBrowser );
17 use POSIX;
18 use URI::Escape;
19 use HTML::Entities;
20 use DB_File;
21 use Benchmark;
22
23 use lib "../lib";
24
25 use Deb::Versions;
26 use Packages::Search qw( :all );
27 use Packages::HTML ();
28
29 my $thisscript = $Packages::HTML::SEARCH_CGI;
30 my $HOME = "http://www.debian.org";
31 my $ROOT = "";
32 my $SEARCHPAGE = "http://packages.debian.org/";
33 my @SUITES = qw( oldstable stable testing unstable experimental );
34 my @SECTIONS = qw( main contrib non-free );
35 my @ARCHIVES = qw( us security installer );
36 my @ARCHITECTURES = qw( alpha amd64 arm hppa hurd-i386 i386 ia64
37                         kfreebsd-i386 mips mipsel powerpc s390 sparc );
38 my %SUITES = map { $_ => 1 } @SUITES;
39 my %SECTIONS = map { $_ => 1 } @SECTIONS;
40 my %ARCHIVES = map { $_ => 1 } @ARCHIVES;
41 my %ARCHITECTURES = map { $_ => 1 } @ARCHITECTURES;
42
43 $ENV{PATH} = "/bin:/usr/bin";
44
45 # Read in all the variables set by the form
46 my $input;
47 if ($ARGV[0] && ($ARGV[0] eq 'php')) {
48         $input = new CGI(\*STDIN);
49 } else {
50         $input = new CGI;
51 }
52
53 my $pet0 = new Benchmark;
54 # use this to disable debugging in production mode completly
55 my $debug_allowed = 1;
56 my $debug = $debug_allowed && $input->param("debug");
57 $debug = 0 if not defined($debug);
58 $Search::Param::debug = 1 if $debug > 1;
59
60 # If you want, just print out a list of all of the variables and exit.
61 print $input->header if $debug;
62 # print $input->dump;
63 # exit;
64
65 if (my $path = $input->param('path')) {
66     my @components = map { lc $_ } split /\//, $path;
67
68     foreach (@components) {
69         if ($SUITES{$_}) {
70             $input->param('suite', $_);
71         } elsif ($SECTIONS{$_}) {
72             $input->param('section', $_);
73         } elsif ($ARCHIVES{$_}) {
74             $input->param('archive', $_);
75         }elsif ($ARCHITECTURES{$_}) {
76             $input->param('arch', $_);
77         }
78     }
79 }
80
81 my ( $format, $keyword, $case, $subword, $exact, $searchon,
82      @suites, @sections, @archs  );
83
84 my %params_def = ( keywords => { default => undef,
85                                  match => '^\s*([-+\@\w\/.:]+)\s*$',
86                                  var => \$keyword },
87                    suite => { default => 'stable', match => '^(\w+)$',
88                               alias => 'version', array => ',',
89                               var => \@suites,
90                               replace => { all => \@SUITES } },
91                    case => { default => 'insensitive', match => '^(\w+)$',
92                              var => \$case },
93 #                  official => { default => 0, match => '^(\w+)$' },
94 #                  use_cache => { default => 1, match => '^(\w+)$' },
95                    subword => { default => 0, match => '^(\w+)$',
96                                 var => \$subword },
97                    exact => { default => undef, match => '^(\w+)$',
98                               var => \$exact },
99                    searchon => { default => 'all', match => '^(\w+)$',
100                                  var => \$searchon },
101                    section => { default => 'all', match => '^([\w-]+)$',
102                                 alias => 'release', array => ',',
103                                 var => \@sections,
104                                 replace => { all => \@SECTIONS } },
105                    arch => { default => 'any', match => '^(\w+)$',
106                              array => ',', var => \@archs, replace =>
107                              { any => \@ARCHITECTURES } },
108                    archive => { default => 'all', match => '^(\w+)$',
109                                 array => ',', replace =>
110                                 { all => \@ARCHIVES } },
111                    format => { default => 'html', match => '^(\w+)$',
112                                var => \$format },
113                    );
114 my %opts;
115 my %params = Packages::Search::parse_params( $input, \%params_def, \%opts );
116
117 #XXX: Don't use alternative output formats yet
118 $format = 'html';
119
120 if ($format eq 'html') {
121     print $input->header;
122 } elsif ($format eq 'xml') {
123 #    print $input->header( -type=>'application/rdf+xml' );
124     print $input->header( -type=>'text/plain' );
125 }
126
127 if ($params{errors}{keywords}) {
128     print "Error: keyword not valid or missing" if $format eq 'html';
129     exit 0;
130 }
131
132 my $case_bool = ( $case !~ /insensitive/ );
133 $exact = !$subword unless defined $exact;
134
135 # for URL construction
136 my $suites_param = join ',', @{$params{values}{suite}{no_replace}};
137 my $sections_param = join ',', @{$params{values}{section}{no_replace}};
138 my $archs_param = join ',', @{$params{values}{arch}{no_replace}};
139
140 # for output
141 my $keyword_enc = encode_entities $keyword;
142 my $searchon_enc = encode_entities $searchon;
143 my $suites_enc = encode_entities join ', ', @{$params{values}{suite}{no_replace}};
144 my $sections_enc = encode_entities join ', ', @{$params{values}{section}{no_replace}};
145 my $archs_enc = encode_entities join ', ',  @{$params{values}{arch}{no_replace}};
146 my $pet1 = new Benchmark;
147 my $petd = timediff($pet1, $pet0);
148 print "DEBUG: Parameter evaluation took ".timestr($petd)."<br>" if $debug;
149
150 if ($format eq 'html') {
151 print Packages::HTML::header( title => 'Package Search Results' ,
152                               lang => 'en',
153                               title_tag => 'Debian Package Search Results',
154                               print_title_above => 1,
155                               print_search_field => 'packages',
156                               search_field_values => { 
157                                   keywords => $keyword_enc,
158                                   searchon => $searchon,
159                                   arch => $archs_enc,
160                                   suite => $suites_enc,
161                                   section => $sections_enc,
162                                   subword => $subword,
163                                   exact => $exact,
164                                   case => $case,
165                                   },
166                               );
167 }
168
169 # read the configuration
170 my $topdir;
171 if (!open (C, "../config.sh")) {
172     print "\nInternal Error: Cannot open configuration file.\n\n"
173 if $format eq 'html';
174     exit 0;
175 }
176 while (<C>) {
177     $topdir = $1 if (/^\s*topdir="?(.*)"?\s*$/);
178 }
179 close (C);
180
181 my $DBDIR = $topdir . "/files/db";
182 my $search_on_sources = 0;
183
184 my $st0 = new Benchmark;
185 my @results;
186 my $too_many_hits;
187 if ($searchon eq 'sourcenames') {
188     $search_on_sources = 1;
189 }
190
191 my %suites = map { $_ => 1 } @suites;
192 my %sections = map { $_ => 1 } @sections;
193 my %archs = map { $_ => 1 } @archs;
194
195 print "DEBUG: suites=@suites, sections=@sections, archs=@archs<br>"
196     if $debug > 2;
197
198 sub read_entry {
199     my ($hash, $key, $results) = @_;
200     my $result = $hash->{$key};
201     foreach (split /\000/, $result) {
202         my @data = split ( /\s/, $_, 7 );
203         print "DEBUG: Considering entry ".join( ':', @data)."<br>" if $debug > 2;
204         if ($suites{$data[0]} && ($archs{$data[1]} || $data[1] eq 'all')
205             && $sections{$data[2]}) {
206             print "DEBUG: Using entry ".join( ':', @data)."<br>" if $debug > 2;
207             push @$results, [ $key, @data ];
208         }
209     }
210 }
211 sub read_src_entry {
212     my ($hash, $key, $results) = @_;
213     my $result = $hash->{$key};
214
215     foreach (split /\000/, $result) {
216         my @data = split ( /\s/, $_, 5 );
217         print "DEBUG: Considering entry ".join( ':', @data)."<br>" if $debug > 2;
218         if ($suites{$data[0]} && $sections{$data[1]}) {
219             print "DEBUG: Using entry ".join( ':', @data)."<br>" if $debug > 2;
220             push @$results, [ $key, @data ];
221         }
222     }
223 }
224 sub do_names_search {
225     my ($keyword, $file, $postfix_file, $read_entry, $opts) = @_;
226     my @results;
227
228     $keyword = lc $keyword unless $opts->{case_bool};
229     
230     my $obj = tie my %packages, 'DB_File', "$DBDIR/$file", O_RDONLY, 0666, $DB_BTREE
231         or die "couldn't tie DB $DBDIR/$file: $!";
232     
233     if ($opts->{exact}) {
234         &$read_entry( \%packages, $keyword, \@results );
235     } else {
236         my ($key, $prefixes) = ($keyword, '');
237         my %pkgs;
238         my $p_obj = tie my %pref, 'DB_File', "$DBDIR/$postfix_file", O_RDONLY, 0666, $DB_BTREE
239             or die "couldn't tie postfix db $DBDIR/$postfix_file: $!";
240         $p_obj->seq( $key, $prefixes, R_CURSOR );
241         while (index($key, $keyword) >= 0) {
242             if ($prefixes =~ /^\001(\d+)/o) {
243                 $too_many_hits += $1;
244             } else {
245                 foreach (split /\000/o, $prefixes) {
246                     $_ = '' if $_ eq '^';
247                     print "DEBUG: add word $_$key<br>" if $debug > 2;
248                     $pkgs{$_.$key}++;
249                 }
250             }
251             last if $p_obj->seq( $key, $prefixes, R_NEXT ) != 0;
252             last if $too_many_hits or keys %pkgs >= 100;
253         }
254         
255         my $no_results = keys %pkgs;
256         if ($too_many_hits || ($no_results >= 100)) {
257             $too_many_hits += $no_results;
258             %pkgs = ( $keyword => 1 );
259         }
260         foreach my $pkg (sort keys %pkgs) {
261             &$read_entry( \%packages, $pkg, \@results );
262         }
263     }
264     return \@results;
265 }
266 sub do_fulltext_search {
267     my ($keword, $file, $mapping, $lookup, $read_entry, $opts) = @_;
268     my @results;
269
270     my @lines;
271     my $regex;
272     if ($opts->{case_bool}) {
273         if ($opts->{exact}) {
274             $regex = qr/\b\Q$keyword\E\b/o;
275         } else {
276             $regex = qr/\Q$keyword\E/o;
277         }
278     } else {
279         if ($exact) {
280             $regex = qr/\b\Q$keyword\E\b/io;
281         } else {
282             $regex = qr/\Q$keyword\E/io;
283         }
284     }
285
286     open DESC, '<', "$DBDIR/$file"
287         or die "couldn't open $DBDIR/$file: $!";
288     while (<DESC>) {
289         $_ =~ $regex or next;
290         print "DEBUG: Matched line $.<br>" if $debug > 2;
291         push @lines, $.;
292     }
293     close DESC;
294
295     tie my %packages, 'DB_File', "$DBDIR/$lookup", O_RDONLY, 0666, $DB_BTREE
296         or die "couldn't tie DB $DBDIR/$lookup: $!";
297     tie my %did2pkg, 'DB_File', "$DBDIR/$mapping", O_RDONLY, 0666, $DB_BTREE
298         or die "couldn't tie DB $DBDIR/$mapping: $!";
299
300     my %tmp_results;
301     foreach my $l (@lines) {
302         my $result = $did2pkg{$l};
303         foreach (split /\000/o, $result) {
304             my @data = split /\s/, $_, 3;
305             next unless $archs{$data[2]};
306             $tmp_results{$data[0]}++;
307         }
308     }
309     foreach my $pkg (keys %tmp_results) {
310         &$read_entry( \%packages, $pkg, \@results ); 
311     }
312     return \@results;
313 }
314
315 if ($searchon eq 'names') {
316     push @results, @{ do_names_search( $keyword, 'packages_small.db',
317                                        'package_postfixes.db',
318                                        \&read_entry, \%opts ) };
319 } elsif ($searchon eq 'sourcenames') {
320     push @results, @{ do_names_search( $keyword, 'sources_small.db',
321                                        'source_postfixes.db',
322                                        \&read_src_entry, \%opts ) };
323 } else {
324     push @results, @{ do_names_search( $keyword, 'packages_small.db',
325                                        'package_postfixes.db',
326                                        \&read_entry, \%opts ) };
327     push @results, @{ do_fulltext_search( $keyword, 'descriptions.txt',
328                                           'descriptions_packages.db',
329                                           'packages_small.db',
330                                           \&read_entry, \%opts ) };
331 }
332
333 my $st1 = new Benchmark;
334 my $std = timediff($st1, $st0);
335 print "DEBUG: Search took ".timestr($std)."<br>" if $debug;
336
337 if ($format eq 'html') {
338     my $suite_wording = $suites_enc eq "all" ? "all suites"
339         : "suite(s) <em>$suites_enc</em>";
340     my $section_wording = $sections_enc eq 'all' ? "all sections"
341         : "section(s) <em>$sections_enc</em>";
342     my $arch_wording = $archs_enc eq 'any' ? "all architectures"
343         : "architecture(s) <em>$archs_enc</em>";
344     if (($searchon eq "names") || ($searchon eq 'sourcenames')) {
345         my $source_wording = $search_on_sources ? "source " : "";
346         my $exact_wording = $exact ? "named" : "that names contain";
347         print "<p>You have searched for ${source_wording}packages $exact_wording <em>$keyword_enc</em> in $suite_wording, $section_wording, and $arch_wording.</p>";
348     } else {
349         my $exact_wording = $exact ? "" : " (including subword matching)";
350         print "<p>You have searched for <em>$keyword_enc</em> in packages names and descriptions in $suite_wording, $section_wording, and $arch_wording$exact_wording.</p>";
351     }
352 }
353
354 if ($too_many_hits) {
355 print "<p><strong>Your search was too wide so we will only display exact matches. At least <em>$too_many_hits</em> results have been omitted and will not be displayed. Please consider using a longer keyword or more keywords.</strong></p>";
356 }
357
358 if (!@results) {
359     if ($format eq 'html') {
360         my $keyword_esc = uri_escape( $keyword );
361         my $printed = 0;
362         if (($searchon eq "names") || ($searchon eq 'sourcenames')) {
363             if (($suites_enc eq 'all')
364                 && ($archs_enc eq 'any')
365                 && ($sections_enc eq 'all')) {
366                 print "<p><strong>Can't find that package.</strong></p>\n";
367             } else {
368                 print "<p><strong>Can't find that package, at least not in that suite ".
369                     ( $search_on_sources ? "" : " and on that architecture" ).
370                     ".</strong></p>\n";
371             }
372             
373             if ($exact) {
374                 $printed = 1;
375                 print "<p>You have searched only for exact matches of the package name. You can try to search for <a href=\"$thisscript?exact=0&amp;searchon=$searchon&amp;suite=$suites_param&amp;case=$case&amp;section=$sections_param&amp;keywords=$keyword_esc&amp;arch=$archs_param\">package names that contain your search string</a>.</p>";
376             }
377         } else {
378             if (($suites_enc eq 'all')
379                 && ($archs_enc eq 'any')
380                 && ($sections_enc eq 'all')) {
381                 print "<p><strong>Can't find that string.</strong></p>\n";
382             } else {
383                 print "<p><strong>Can't find that string, at least not in that suite ($suites_enc, section $sections_enc) and on that architecture ($archs_enc).</strong></p>\n";
384             }
385             
386             unless ($subword) {
387                 $printed = 1;
388                 print "<p>You have searched only for words exactly matching your keywords. You can try to search <a href=\"$thisscript?subword=1&amp;searchon=$searchon&amp;suite=$suites_param&amp;case=$case&amp;section=$sections_param&amp;keywords=$keyword_esc&amp;arch=$archs_param\">allowing subword matching</a>.</p>";
389             }
390         }
391         print "<p>".( $printed ? "Or you" : "You" )." can try a different search on the <a href=\"$SEARCHPAGE#search_packages\">Packages search page</a>.</p>";
392         
393         &printfooter;
394     }
395     exit;
396 }
397
398 my (%pkgs, %sect, %part, %desc, %binaries);
399
400 unless ($search_on_sources) {
401     foreach (@results) {
402         my ($pkg_t, $suite, $arch, $section, $subsection,
403             $priority, $version, $desc) = @$_;
404         
405         my ($package) = $pkg_t =~ m/^(.+)/; # untaint
406         $pkgs{$package}{$suite}{$version}{$arch} = 1;
407         $sect{$package}{$suite}{$version} = $subsection;
408         $part{$package}{$suite}{$version} = $section unless $section eq 'main';
409         
410         $desc{$package}{$suite}{$version} = $desc;
411
412     }
413
414     if ($format eq 'html') {
415         my ($start, $end) = multipageheader( scalar keys %pkgs );
416         my $count = 0;
417         
418         foreach my $pkg (sort keys %pkgs) {
419             $count++;
420             next if $count < $start or $count > $end;
421             printf "<h3>Package %s</h3>\n", $pkg;
422             print "<ul>\n";
423             foreach my $ver (@SUITES) {
424                 if (exists $pkgs{$pkg}{$ver}) {
425                     my @versions = version_sort keys %{$pkgs{$pkg}{$ver}};
426                     my $part_str = "";
427                     if ($part{$pkg}{$ver}{$versions[0]}) {
428                         $part_str = "[<span style=\"color:red\">$part{$pkg}{$ver}{$versions[0]}</span>]";
429                     }
430                     printf "<li><a href=\"$ROOT/%s/%s/%s\">%s</a> (%s): %s   %s\n",
431                     $ver, $sect{$pkg}{$ver}{$versions[0]}, $pkg, $ver, $sect{$pkg}{$ver}{$versions[0]}, $desc{$pkg}{$ver}{$versions[0]}, $part_str;
432                     
433                     foreach my $v (@versions) {
434                         printf "<br>%s: %s\n",
435                         $v, join (" ", (sort keys %{$pkgs{$pkg}{$ver}{$v}}) );
436                     }
437                     print "</li>\n";
438                 }
439             }
440             print "</ul>\n";
441         }
442     } elsif ($format eq 'xml') {
443         require RDF::Simple::Serialiser;
444         my $rdf = new RDF::Simple::Serialiser;
445         $rdf->addns( debpkg => 'http://packages.debian.org/xml/01-debian-packages-rdf' );
446         my @triples;
447         foreach my $pkg (sort keys %pkgs) {
448             foreach my $ver (@SUITES) {
449                 if (exists $pkgs{$pkg}{$ver}) {
450                     my @versions = version_sort keys %{$pkgs{$pkg}{$ver}};
451                     foreach my $version (@versions) {
452                         my $id = "$ROOT/$ver/$sect{$pkg}{$ver}{$version}/$pkg/$version";
453                         push @triples, [ $id, 'debpkg:package', $pkg ];
454                         push @triples, [ $id, 'debpkg:version', $version ];
455                         push @triples, [ $id, 'debpkg:section', $sect{$pkg}{$ver}{$version}, ];
456                         push @triples, [ $id, 'debpkg:suite', $ver ];
457                         push @triples, [ $id, 'debpkg:shortdesc', $desc{$pkg}{$ver}{$version} ];
458                         push @triples, [ $id, 'debpkg:part', $part{$pkg}{$ver}{$version} || 'main' ];
459                         foreach my $arch (sort keys %{$pkgs{$pkg}{$ver}{$version}}) {
460                             push @triples, [ $id, 'debpkg:architecture', $arch ];
461                         }
462                     }
463                 }
464             }
465         }
466         
467         print $rdf->serialise(@triples);
468     }
469 } else {
470     foreach (@results) {
471         my ($package, $suite, $section, $subsection, $priority,
472             $version, $binaries) = @$_;
473         
474         $pkgs{$package}{$suite} = $version;
475         $sect{$package}{$suite}{source} = $subsection;
476         $part{$package}{$suite}{source} = $section unless $section eq 'main';
477
478         $binaries{$package}{$suite} = [ sort split( /\s*,\s*/, $binaries ) ];
479     }
480
481     if ($format eq 'html') {
482         my ($start, $end) = multipageheader( scalar keys %pkgs );
483         my $count = 0;
484         
485         foreach my $pkg (sort keys %pkgs) {
486             $count++;
487             next if ($count < $start) or ($count > $end);
488             printf "<h3>Source package %s</h3>\n", $pkg;
489             print "<ul>\n";
490             foreach my $ver (@SUITES) {
491                 if (exists $pkgs{$pkg}{$ver}) {
492                     my $part_str = "";
493                     if ($part{$pkg}{$ver}{source}) {
494                         $part_str = "[<span style=\"color:red\">$part{$pkg}{$ver}{source}</span>]";
495                     }
496                     printf "<li><a href=\"$ROOT/%s/source/%s\">%s</a> (%s): %s   %s", $ver, $pkg, $ver, $sect{$pkg}{$ver}{source}, $pkgs{$pkg}{$ver}, $part_str;
497                     
498                     print "<br>Binary packages: ";
499                     my @bp_links;
500                     foreach my $bp (@{$binaries{$pkg}{$ver}}) {
501                         my $sect = 'section';
502                         
503                         my $bp_link;
504                         if ($sect) {
505                             $bp_link = sprintf( "<a href=\"$ROOT/%s/%s/%s\">%s</a>",
506                                                 $ver, $sect, uri_escape( $bp ),  $bp );
507                         } else {
508                             $bp_link = $bp;
509                         }
510                         push @bp_links, $bp_link;
511                     }
512                     print join( ", ", @bp_links );
513                     print "</li>\n";
514                 }
515             }
516             print "</ul>\n";
517         }
518     } elsif ($format eq 'xml') {
519         require RDF::Simple::Serialiser;
520         my $rdf = new RDF::Simple::Serialiser;
521         $rdf->addns( debpkg => 'http://packages.debian.org/xml/01-debian-packages-rdf' );
522         my @triples;
523         foreach my $pkg (sort keys %pkgs) {
524             foreach my $ver (@SUITES) {
525                 if (exists $pkgs{$pkg}{$ver}) {
526                     my $id = "$ROOT/$ver/source/$pkg";
527
528                     push @triples, [ $id, 'debpkg:package', $pkg ];
529                     push @triples, [ $id, 'debpkg:type', 'source' ];
530                     push @triples, [ $id, 'debpkg:section', $sect{$pkg}{$ver}{source} ];
531                     push @triples, [ $id, 'debpkg:version', $pkgs{$pkg}{$ver} ];
532                     push @triples, [ $id, 'debpkg:part', $part{$pkg}{$ver}{source} || 'main' ];
533                     
534                     foreach my $bp (@{$binaries{$pkg}{$ver}}) {
535                         push @triples, [ $id, 'debpkg:binary', $bp ];
536                     }
537                 }
538             }
539         }
540         print $rdf->serialise(@triples);
541     }
542 }
543
544 if ($format eq 'html') {
545     &printindexline( scalar keys %pkgs );
546     &printfooter;
547 }
548
549 exit;
550
551 sub printindexline {
552     my $no_results = shift;
553
554     my $index_line;
555     if ($no_results > $opts{number}) {
556         
557         $index_line = prevlink($input,\%params)." | ".
558             indexline( $input, \%params, $no_results)." | ".
559             nextlink($input,\%params, $no_results);
560         
561         print "<p style=\"text-align:center\">$index_line</p>";
562     }
563 }
564
565 sub multipageheader {
566     my $no_results = shift;
567
568     my ($start, $end);
569     if ($opts{number} =~ /^all$/i) {
570         $start = 1;
571         $end = $no_results;
572         $opts{number} = $no_results;
573     } else {
574         $start = Packages::Search::start( \%params );
575         $end = Packages::Search::end( \%params );
576         if ($end > $no_results) { $end = $no_results; }
577     }
578
579     print "<p>Found <em>$no_results</em> matching packages,";
580     if ($end == $start) {
581         print " displaying package $end.</p>";
582     } else {
583         print " displaying packages $start to $end.</p>";
584     }
585
586     printindexline( $no_results );
587
588     if ($no_results > 100) {
589         print "<p>Results per page: ";
590         my @resperpagelinks;
591         for (50, 100, 200) {
592             if ($opts{number} == $_) {
593                 push @resperpagelinks, $_;
594             } else {
595                 push @resperpagelinks, resperpagelink($input,\%params,$_);
596             }
597         }
598         if ($params{values}{number}{final} =~ /^all$/i) {
599             push @resperpagelinks, "all";
600         } else {
601             push @resperpagelinks, resperpagelink($input, \%params,"all");
602         }
603         print join( " | ", @resperpagelinks )."</p>";
604     }
605     return ( $start, $end );
606 }
607
608 sub printfooter {
609 print <<END;
610 </div>
611
612 <hr class="hidecss">
613 <p style="text-align:right;font-size:small;font-stlye:italic"><a href="$SEARCHPAGE">Packages search page</a></p>
614
615 </div>
616 END
617
618 my $pete = new Benchmark;
619 my $petd = timediff($pete, $pet0);
620 print "Total page evaluation took ".timestr($petd)."<br>"
621     if $debug_allowed;
622 print $input->end_html;
623 }
624
625 # vim: ts=8 sw=4