ファイル名: w/LOG.cgi

#!/usr/local/bin/perl

if (!open(IN,"wwwcount.acc")) { print "openエラー\n"; }
@lines = <IN>;
close(IN);

$formdata = $ENV{'QUERY_STRING'};
@pairs = split(/&/,$formdata);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
     $FORM{$name} = $value;}

$Title = 'LOG';
$BODY = '<BODY background="23.gif" BGCOLOR="#000000" TEXT="#C0C0C0" LINK="#C0C0C0" VLINK="#C0C0C0" ALINK="#C0C0C0">';
print "Content-type: text/html\n\n";

print "<HTML><HEAD><TITLE>$Title</TITLE></HEAD>\n";
print "$BODY\n";
print "<center>\n";
print "<font size = +2><i>LOG</i></font>\n";
print "<BR>\n";
print "<a href=\"LOG.cgi?action=all\">内容</a>\n";
print "<a href=\"LOG.cgi?action=time\">時間</a>\n";
print "<a href=\"LOG.cgi\">リロード</a>\n";
print "<HR>\n";
print "</center>\n";
if ($FORM{'action'} eq 'time') { &jikan
} else {
foreach $line (@lines) {
chop($line);
($COUNT,$TIME,$ADDR,$HOST,$USER,$SERVER,$AGENT,$REFER,$FROM) = split(/,/, $line);
$junnban{$ADDR,$TIME} = $line;

}
for (sort by_junnban keys(%junnban)){
push ( @kazu,$_ );
$kazu = @kazu;
print " <blockquote>\n";
print " $kazu\n";
print " <FONT COLOR =\"#00FF00\">$_ </FONT><BR>\n";
if ($FORM{'action'} eq 'all') {
print " <blockquote>\n";
print "$junnban{$_}\n";
print " </blockquote>\n";
}
print " </blockquote>\n";
print "<HR NOSHADE SIZE=1 WIDTH=\"700\" ALIGN=CENTER>\n";
}
}

sub by_junnban {
($junnban{$a} <=> $junnban{$b}) || ($a cmp $b)
}
print "</BODY>\n";
print "</HTML>\n";
exit;

sub jikan {
foreach $line (@lines) {
chop($line);
($COUNT,$TIME,$ADDR,$HOST,$USER,$SERVER,$AGENT,$REFER,$FROM) = split(/,/, $line);
print " <blockquote>\n";
print "$TIME \n";
print " $ADDR \n";
print "<HR NOSHADE SIZE=1 WIDTH=\"700\" ALIGN=CENTER>\n";
print " </blockquote>\n";

}

}