logÈÀÏ·Î ÀúÀåµÇ´Â Ä«¿îÅ͵¥ÀÌÅÍÁß Æ¯Á¤³¯Â¥¸¸À» ÃßÃâÇÏ¿© ±×°ªÀ» ´õÇÏ°í ½Í½À´Ï´Ù.
Âü°í·Î ¾Æ·¡ ¼Ò½º´Â 2000-02-06°ú°°À̳¯Â¥º°·Î Ä«¿îÅÍµÈ µ¥ÀÌŸ¸¦ Àоîµé¿© Á¢¼ÓȽ¼ö,ipÁÖ¼Ò,ºê¶ó¿ìÀú¸¦ ¹àÇôÁÝ´Ï´Ù.
Àú´Â À̼ҽº¸¦ ¼öÁ¤ÇÏ¿© À§ÀÇ 2000-02-06°ú °°Àº µ¥ÀÌŸµé Áß¿¡¼ ƯÁ¤³¯Â¥µé¸¸À» ´õÇÏ¿©¼ Åë°è¸¦ ³»°í ½Í½À´Ï´Ù. °í¼ö´ÔµéÀÇ °í°ßºÎŹµå¸³´Ï´Ù.
#!/usr/bin/perl
use Time::Local;
get_log( init() );
####################################################
sub get_log {
my %GIL = @_;
my @yoil = qw(ÀÏ ¿ù È ¼ö ¸ñ ±Ý Åä);
#LOGÇü½Ä: "$year-$mon-$day$DELIM$hour:$min$DELIM$ip$DELIM$host$DELIM$agent
";
my $DELIM = chr(30);
my ($file, $date_title);
if ( $GIL{day} ) {
$file = "log/$GIL{day}";
my ($sec,$min,$hour,$day,$mon,$year, $week) =
map { sprintf
%.2d
,$_ } localtime get_time($GIL{day});
$mon ;
$year = 1900 if length $year <=3;
$date_title = "
$GIL{day} ¹æ¹®ÀÚ [ $yoil[$week]¿äÀÏ ]";
} else {
my ($sec,$min,$hour,$day,$mon,$year, $week) =
map { sprintf
%.2d
,$_ } localtime;
$mon ;
$year = 1900 if length $year <=3;
$file = "log/$year-$mon-$day";
$date_title = "
¿À´Ã ¹æ¹®ÀÚ $year³â $mon¿ù $dayÀÏ [ $yoil[$week]¿äÀÏ ]";
}
my (%COUNT, %LOG);
open GIL, $file;
for (
) {
my ($date, $time, $ip, $host, $agent) = split /$DELIM/, $_;
$count = $COUNT{ $ip };
$ip2 = $host ? "$ip ($host)" : $ip;
$agent =~ s@(MSIE)@$1@;
$agent =~ s/compatible; //i;
$agent =~ s/Windows/Win/;
$LOG{ $ip } = [ "$time", "". "$count | $time | ".
"$ip2 | $agent |
" ];
}
close GIL;
my $x = 0;
my @result;
for ( sort { $a->[0] cmp $b->[0] } values %LOG ) {
push @result, "$_->[1]
";
$x ;
}
print "Content-type: text/html
";
print<
¹æ¹® ±â·Ï
Ƚ¼ö | ½Ã°£ | Á¢¼ÓÁÖ¼Ò | »ç¿ë ºê¶ó¿ìÁ® | @result
|
END
}
####################################################
sub init {
my (%GIL, $buffer);
if ($ENV{
REQUEST_METHOD
} eq "POST") {
read(STDIN, $buffer, $ENV{
CONTENT_LENGTH
});
}
else {
$buffer = $ENV{
QUERY_STRING
};
}
for $item (split /&/, $buffer) {
my ($name, $value) = split /=/, $item;
$name =~ tr/ / /; $name =~ s/%(..)/chr(hex($1))/ge;
$value =~ tr/ / /; $value =~ s/%(..)/chr(hex($1))/ge;
$GIL{$name} = $value;
}
%GIL;
}
####################################################
sub get_time {
my ($year, $mon, $day) = split
-
, shift;
$year -= 1900;
timelocal(1, 0, 0, $day, $mon - 1, $year)
}
__END__