#!/usr/bin/perl
$|=1;
$logname = "newhhlog"; # アクセスログの場所
$lognum = "./lognum.txt";
$CONNECTION = $ENV{'HTTP_PROXY_CONNECTION'};
$INFO = $ENV{'HTTP_CACHE_INFO'};
$addr = $ENV{'REMOTE_ADDR'};
$host = $ENV{'REMOTE_HOST'};
if ($host eq $addr) { $host = gethostbyaddr(pack('C4',split(/\./,$host)),2) || $addr; }
$via = $ENV{'HTTP_VIA'};
$xfor = $ENV{'HTTP_X_FORWARDED_FOR'};
$for = $ENV{'HTTP_FORWARDED'};
$agent = $ENV{'HTTP_USER_AGENT'};
$proxy = 0;
$body = '
';
if ( $proxy eq '1') { &proxy;}
$ENV{'TZ'} = "JST-9";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
@wday_array = ('日','月','火','水','木','金','土');
$date_now = sprintf("%01d月%01d日(%s)%02d時%02d分%02d秒",$mon +1,$mday,$wday_array[$wday],$hour,$min,$sec);
print "Content-type: text/html\n\n";
print "掲示板アクセス統計\n";
print "\n";
print "$body\n";
print "\n";
print "
\n";
print "\n";
print " \n";
print " JAPANESE TRASHアクセス統計 | \n";
print "
\n";
print "
\n";
print "$date_now現在
\n";
if (!open(LOG,"$lognum")) { &error('0'); }
$num = ;
close(LOG);
$logfile = "$logname"."$num"."\.txt";
if (!open(LOG,"$logfile")) { &error('0'); }
@log=;
close(LOG);
foreach $log (@log) {
chomp ($log);
$log =~ s/<\;/g;
$log =~ s/>/>\;/g;
@host = split(",",$log);
if ($host[1]){push (@lank,"$host[1]");}
}
%uniq = (); # ハッシュ %uniq を初期化
@lank2 = (); # 配列 @lank2 を初期化
foreach $num (@lank) { # @lank の要素を $num でまわす
if (!defined($uniq{$num})) { # 定義されているかどうか(重複を)調べる
$uniq{$num} = 0;}
$uniq{"$num"} ++;
}
while (($key,$value) = each %uniq){
$value = sprintf("%03d",$value);
push(@lank2,"$value\t$key") ;}
@sorted_lank = sort @lank2;
@sorted_lank = reverse @sorted_lank;
$cou = @lank;
$num = @sorted_lank;
print "\n\n";
print "Ranking | URL |
\n\n";
foreach $lank (@sorted_lank){
@proxy = split ("\t",$lank);
$proxy[0] = sprintf("%01d",$proxy[0]);
unless($proxy[0]=='1' || $proxy[1] =~/jani/){
print "";
print "$proxy[0] | $proxy[1] | ";
print "
\n";
}
}
print "
\n";
print "$cou accesses, $num diffetent kinds of adresses..
\n";
print "$host\n";
print "
\n";
print "\n";
print "掲示板アクセス統計 ver0.3
written by 2代目怒羅絵悶
\n";
print "\n";
exit;
sub error {
# &error(xx); で呼び出されたルーチンは、()内の数字が $error に代入される。
$error = $_[0];
if ($error eq "0") { $error_msg = 'ファイルをオープン出来ません'; }
print "$error_msg
\n";
print "