Handle hostnames with upper-case letters
[webmin.git] / software / file_info.cgi
1 #!/usr/local/bin/perl
2 # file_info.cgi
3 # Display information about a file owned by the package management system
4
5 require './software-lib.pl';
6 &ReadParse();
7 $f = $in{'file'};
8 &ui_print_header(undef, $text{'file_title'}, "", "file_info");
9
10 $f =~ s/\/$//;
11 if ($f !~ /^\//) {
12         # if the filename is not absolute, look for it
13         foreach $p (split(/:/, $ENV{'PATH'})) {
14                 last if (&installed_file("$p/$f"));
15                 }
16         }
17 else {
18         # absolute path.. must exist in DB
19         &installed_file($f);
20         }
21
22 if (!%file) {
23         print "<b>",&text('file_notfound', "<tt>$f</tt>"),"</b><p>\n";
24         }
25 else {
26         # display file info
27         $nc = "width=10% nowrap";
28         print &ui_table_start($text{'file_title'}, "width=100%", 4);
29
30         print &ui_table_row($text{'file_path'},
31                             "<tt>".&html_escape($file{'path'})."</tt>", 3);
32
33         print &ui_table_row($text{'file_type'},
34                             $type_map[$file{'type'}]);
35
36         if ($file{'type'} != 3 && $file{'type'} != 4) {
37                 print &ui_table_row($text{'file_perms'}, $file{'mode'});
38
39                 print &ui_table_row($text{'file_owner'}, $file{'user'});
40                 print &ui_table_row($text{'file_group'}, $file{'group'});
41
42                 if ($file{'type'} == 0) {
43                         print &ui_table_row($text{'file_size'}, $file{'size'});
44                         }
45                 }
46         else {
47                 print &ui_table_row($text{'file_link'},
48                         "<tt>".&html_escape($file{'link'})."</tt>", 3);
49                 }
50         print &ui_table_end();
51
52         # Show packages containing the file (usually only one)
53         print &ui_columns_start([ $text{'file_pack'},
54                                   $text{'file_class'},
55                                   $text{'file_desc'} ], 100);
56         @pkgs = split(/\s+/, $file{'packages'});
57         @vers = split(/\s+/, $file{'versions'});
58         $n = &list_packages(@pkgs);
59         for($j=0; $j<@pkgs; $j++) {
60                 for($i=0; $i<$n; $i++) {
61                         next if ($vers[$i] &&
62                                  $packages{$i,'version'} ne $vers[$j] ||
63                                  $packages{$i,'name'} ne $pkgs[$j]);
64                         local @cols;
65                         push(@cols, "<a href=\"edit_pack.cgi?package=".
66                               &urlize($pkgs[$j])."&version=".&urlize($vers[$j]).
67                               "\">$pkgs[$j]</a>");
68                         $c = $packages{$i,'class'};
69                         push(@cols, $c || $text{'file_none'});
70                         push(@cols, $packages{$i,'desc'});
71                         print &ui_columns_row(\@cols);
72                         }
73                 }
74         print &ui_columns_end();
75         }
76
77 &ui_print_footer("", $text{'index_return'});
78