3 # Display the report for some log file
5 require './sarg-lib.pl';
8 $file = $ENV{'PATH_INFO'} || "/index.html";
9 $file =~ /\.\./ || $file =~ /\<|\>|\||\0/ && &error($text{'view_efile'});
11 $conf = &get_config();
12 $odir = &find_value("output_dir", $conf);
13 $odir ||= &find_value("output_dir", $conf, 1);
14 $odir || &error($text{'view_eodir'});
16 &is_under_directory($odir, $full) || &error($text{'view_efile'});
19 if (-d $full && -r "$full/index.html") {
20 $full = "$full/index.html";
23 # Display file contents
24 if ($full =~ /\.(html|htm)$/i && !$config{'naked'}) {
25 open(FILE, $full) || &error($text{'view_eopen'}." : $full");
26 while(read(FILE, $buf, 1024)) {
30 if ($data =~ /<TITLE>(.*)<\/TITLE>/i) {
33 $data =~ s/^[\000-\377]*<BODY[^>]*>//i;
34 $data =~ s/<\/BODY>[\000-\377]*$//i;
36 &ui_print_header(undef, $title || $text{'view_title'}, "");
37 print "<div id=sarg-report>\n";
40 &ui_print_footer("", $text{'index_return'});
43 # Show directory listing
44 &ui_print_header(undef, $text{'view_title'}, "");
47 foreach $f (sort { lc($a) cmp lc($b) } readdir(DIR)) {
48 next if ($f eq "." || $f eq "..");
49 print "<li><a href='$f/'>$f</a>\n";
53 &ui_print_footer("", $text{'index_return'});
56 # Show RAW file contents
57 open(FILE, $full) || &error($text{'view_eopen'}." : $full");
58 print "Content-type: ",&guess_mime_type($full, "text/plain"),"\n";
60 while(read(FILE, $buf, 1024)) {