View | Details | Raw Unified | Return to bug 11317
Collapse All | Expand All

(-)a/reports/report_files.pl (-6 / +6 lines)
Lines 29-34 use C4::Context; Link Here
29
use C4::Output;
29
use C4::Output;
30
use C4::Koha;
30
use C4::Koha;
31
use File::stat;
31
use File::stat;
32
use Digest::MD5 qw(md5_hex);
32
33
33
my $input      = new CGI;
34
my $input      = new CGI;
34
my $file_id = $input->param("id");
35
my $file_id = $input->param("id");
Lines 50-57 else { Link Here
50
    my @files_list;
51
    my @files_list;
51
	opendir(DIR, $directory);
52
	opendir(DIR, $directory);
52
53
53
    my $i=0;
54
    foreach my $filename (readdir(DIR)) {
54
    foreach my $filename (readdir(DIR)) {
55
	my $id = md5_hex($filename);
55
        my $full_path = "$directory/$filename";
56
        my $full_path = "$directory/$filename";
56
        next if ($filename =~ /^\./ or -d $full_path);
57
        next if ($filename =~ /^\./ or -d $full_path);
57
58
Lines 59-72 else { Link Here
59
        push(@files_list, {name => $filename,
60
        push(@files_list, {name => $filename,
60
                           date => scalar localtime($st->mtime),
61
                           date => scalar localtime($st->mtime),
61
                           size => $st->size,
62
                           size => $st->size,
62
                           id   => $i});
63
                           id   => $id});
63
        $i++;
64
    }
64
    }
65
    closedir(DIR);
65
    closedir(DIR);
66
66
67
    my %files_hash = map { $_->{id} => $_ } @files_list;
67
    # If we received a file_id and it is valid, send the file to the browser
68
    # If we received a file_id and it is valid, send the file to the browser
68
    if(defined $file_id and $file_id >= 0 and $file_id < scalar @files_list){
69
    if(defined $file_id and $file_id >= 0 and exists $files_hash{$file_id} ){
69
        my $filename = $files_list[$file_id]->{name};
70
        my $filename = $files_hash{$file_id}->{name};
70
        binmode STDOUT;
71
        binmode STDOUT;
71
        # Open the selected file and send it to the browser
72
        # Open the selected file and send it to the browser
72
        print $input->header(-type => 'application/x-download',
73
        print $input->header(-type => 'application/x-download',
73
- 

Return to bug 11317