#!/usr/local/bin/perl

print <<EOF;
content-type: text/html

<style type="text/css">
td { 
	font-family: Arial, Helvetica, sans-serif; 
	font-size: 80%;
    background: #cccccc;
}
</style>
</head>
<body bgcolor=#ccdddd>
EOF


open FILE, "<fast_feedback.log";
my $n = 0;
my @comments;
my @points;
my %domains;
my @headers =("funny",
			  "strange",
			  "absurd",
			  "useless",
			  "boring",
			  "clueless",
			  "pointless",
			  "too intellectual",
			  "too primitive",
			  "incomprehensible");

while (<FILE>){
	chomp;
	my ($date, $host, $agent, $comment, @count) = split(/\t/, $_, 14);
	if(length($comment) > 2){
		push @comments, $comment . " ($host)";;
	}
	my $i = 0;
	$domains{$host}++;
	foreach $c (@count){
		if($c eq 'on'){
			$points[$i] ++;
		}
		$i++;
	}
	$n ++;
}
close FILE;


print "es hat " . $n . " eingereichte meldungen";

print "<table>\n";

print " <tr>\n";
my $i = 0;
foreach $x (@headers){
	print "  <td>$x</td>\n";
}
print " </tr>\n";

print " <tr>\n";
foreach $x (@points){
	$x ||= 0;
	print "  <td align=center>$x</td>\n";
}
print " </tr>\n";

print "</table>\n";

print "Die folgenden Kommentare wurden von AI Engine ausgewählt:";
print "<table>";
foreach $x (@comments){
	print "<tr><td>$x</td></tr>\n";
}
print "</table>";
