File Coverage

blib/lib/Apache/WAP/AutoIndex.pm
Criterion Covered Total %
statement 4 6 66.6
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 6 8 75.0


line stmt bran cond sub pod time code
1             package Apache::WAP::AutoIndex;
2 1     1   690 use strict;
  1         2  
  1         38  
3 1     1   1515 use CGI::WML;
  0            
  0            
4             use Apache::Constants qw(:common);
5              
6             our $VERSION = '0.01';
7             sub handler {
8             my $r = shift;
9             my $cgi = new CGI::WML;
10              
11             my $filename = $r->filename;
12             my $url_filename = $r->uri;
13             $filename =~ s/filelist\.wml$//;
14             $url_filename =~ s/filelist\.wml$//;
15             unless (opendir DH, $filename) { return FORBIDDEN; }
16              
17             my $content = "

Directory $url_filename:
";

18             my $filelink;
19             foreach my $file ( readdir DH ){
20             if (-d "$filename/$file")
21             { $file .= "/"; $filelink = $file . "filelist.wml"; }
22             else { $filelink = $file; }
23             $content .= CGI::a({href => "$filelink"}, "$file");
24             }
25             $content .= "

";
26             close DH;
27              
28             $r->print( $cgi->header(),
29             $cgi->start_wml(),
30             $cgi->template(-content=>$cgi->prev()),
31             $cgi->card(-id=>"dirlist",
32             -title=>"Directory $filename",
33             -content=> $content),
34             $cgi->end_wml() );
35             }
36             1;
37