#! /usr/local/bin/perl ################################################## #BCP-LogViewer v1.03 This program is free. # #(C) BooBooClub 2001-2006 # ################################################## #set data $loglimit = '2'; #read if ($ENV{'REQUEST_METHOD'} eq "POST"){ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else{ $buffer = $ENV{'QUERY_STRING'}; } @pairs = split(/&/,$buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/\r\n|[\r\n]//ig; $FORM{$name} = $value; } #time $ENV{'TZ'}='JST-9'; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $year = ($year + 1900); $mon++; if ($sec < 10) { $sec = "0$sec";} if ($min < 10) { $min = "0$min";} if ($hour < 10){ $hour = "0$hour";} if ($mon < 10) { $mon = "0$mon";} if ($mday < 10){ $mday = "0$mday";} $time = "$year/$mon/$mday $hour:$min:$sec"; $log = $FORM{'ldata'}; #lock #&lock; #branch &html; sub html { open (LOG,"$log"); @logs = ; close (LOG); unlink("$lockfile"); print "Content-type: text/html\n\n"; print '',"\n"; print 'BCP-LogViewer',"\n"; print '',"\n"; print '
',"\n"; print 'BCP-LogViewer',"\n"; print '


',"\n"; print '
',"\n"; print '',"\n"; print '',"\n"; print '
ログ集計期間 : 当月までの ',"$loglimit",'ヶ月間
',"\n"; print '
',"\n"; print '
',"\n"; print '
',"\n"; print '日別アクセス数

',"\n"; print '',"\n"; print '',"\n"; foreach $logs(@logs){ chomp $logs; $logs =~ s/ //g; @elog = split(/:/,$logs); if($elog[1] ne '' && $elog[1] =~ /\D/){ print '',"\n"; print '
日/累計/日計


Log-File Error !
',"\n"; print '
',"\n"; print '
',"\n"; print '',"\n"; print '',"\n"; exit 0; } $elog[0] =~ s/\//./g; if($max < $elog[1]){ $max = $elog[1]; } } foreach $logs(@logs){ chomp $logs; $logs =~ s/ //g; @elog = split(/:/,$logs); $elog[0] =~ s/\//./g; if($elog[1] eq '0'){ print '',"$elog[0]",'/',"$elog[2]",'/',"$elog[1]",':',"\n"; } else{ $num = $elog[1] / $max * 300; print '',"$elog[0]",'/',"$elog[2]",'/',"$elog[1]",':',"\n"; } } print '',"\n"; print '
',"\n"; print '
',"\n"; print '
',"\n"; print '
[Produced by BooBooClub]
',"\n"; print '',"\n"; print '',"\n"; print '',"\n"; print '',"\n"; exit 0; } sub lock{ $lockfile = './lock/lockfile'; $retry = 1; until (symlink("$log", "$lockfile")){ if (++$retry >= 30){ unlink("$lockfile"); exit(0); } sleep(1); } }