Handle hostnames with upper-case letters
[webmin.git] / man / view_howto.cgi
1 #!/usr/local/bin/perl
2 # view_doc.cgi
3 # View some HOWTO doc file
4
5 require './man-lib.pl';
6 &ReadParse();
7
8 $in{'file'} = &simplify_path($in{'file'});
9 $in{'file'} !~ /[\\\&\;\`\'\"\|\*\?\~\<\>\^\(\)\[\]\{\}\$\n\r]/ ||
10         &error($text{'howto_epath'});
11 foreach $h (split(/\s+/, $config{'howto_dir'})) {
12         $ok++ if (&is_under_directory($h, $in{'file'}));
13         }
14 $ok || &error($text{'howto_epath'});
15 -r $in{'file'} || &error($text{'howto_epath'});
16
17 &ui_print_header(undef, $text{'howto_title'}, "");
18
19 # Work out compression format
20 open(FILE, $in{'file'});
21 read(FILE, $two, 2);
22 $qm = quotemeta($in{'file'});
23 if ($two eq "\037\213") {
24         close(FILE);
25         &open_execute_command(FILE, "gunzip -c $qm", 1, 1);
26         }
27 elsif ($two eq "BZ") {
28         close(FILE);
29         &open_execute_command(FILE, "bunzip2 -c $qm", 1, 1);
30         }
31 seek(FILE, 0, 0);
32
33 $out = "<pre>";
34 @for = split(/\s+/, $in{'for'});
35 while($line = <FILE>) {
36         $line = &html_escape($line);
37         foreach $f (@for) {
38                 $line =~ s/.\010//g;
39                 $line =~ s/($f)/<b>$1<\/b>/ig;
40                 }
41         $out .= $line;
42         }
43 close(FILE);
44 $out .= "</pre>";
45 &show_view_table(&text('howto_header', $in{'file'}), $out);
46
47 &ui_print_footer("", $text{'index_return'});
48