1 package Packages::DoIndex;
10 use Packages::Config qw( $TOPDIR );
11 use Packages::I18N::Locale;
14 our @ISA = qw( Exporter );
15 our @EXPORT = qw( do_index do_allpackages );
18 return send_file( 'index', @_ );
21 return send_file( 'allpackages', @_ );
28 my ($file, $params, $opts) = @_;
29 my $cat = $opts->{cat};
31 if ($params->{errors}{suite}) {
32 fatal_error( $cat->g( "suite not valid or not specified" ) );
34 if (@{$opts->{suite}} > 1) {
35 fatal_error( $cat->g( "more than one suite specified for show_static (%s)",
36 "@{$opts->{suite}}" ) );
38 if (@{$opts->{subsection}} > 1) {
39 fatal_error( $cat->g( "more than one subsection specified for show_static (%s)",
40 "@{$opts->{suite}}" ) );
43 my $wwwdir = "$TOPDIR/www";
45 $path .= "source/" if $opts->{source};
46 $path .= "$opts->{suite}[0]/";
47 $path .= "$opts->{archive}[0]/" if @{$opts->{archive}} == 1;
48 $path .= "$opts->{subsection}[0]/" if @{$opts->{subsection}};
49 $path .= "$opts->{priority}[0]/" if @{$opts->{priority}};
52 if ($opts->{lang} ne 'en' and !-f "$wwwdir/$path$file.$opts->{lang}.$opts->{format}") {
55 $path .= "$file.$opts->{lang}.$opts->{format}";
57 unless (@Packages::CGI::fatal_errors) {
59 if (open( INDEX, '<', "$wwwdir/$path" )) {
61 $headers{'-charset'} = 'UTF-8';
62 $headers{'-type'} = get_mime( $opts->{format}, 'text/plain' );
63 $headers{'-content-encoding'} = $encoding{$opts->{format}} if exists $encoding{$opts->{format}};
64 my ($size,$mtime) = (stat("$wwwdir/$path"))[7,9];
65 $headers{'-content-length'} = $size;
66 $headers{'-last-modified'} = gmtime($mtime);
67 print header( %headers );
70 while (read INDEX, $buffer, 4096) {
76 fatal_error( $cat->g( "couldn't read index file %s: %s",