#!/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 " \n"; print " \n"; print "
JAPANESE TRASHアクセス統計
\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; @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 "\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 ""; print "\n"; } } print "
RankingURL
$proxy[0]$proxy[1]

\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 "\n"; exit; } sub proxy { $proxy=0; if($CONNECTION ne ""){ $proxy=1;} if($INFO ne ""){ $proxy=1;} if($via ne ""){ $proxy=1;} if($xfor ne ""){ $proxy=1;} if($for ne ""){ $proxy=1;} if($host =~ /squid|^firewall|proxy|cache|delegate|^dns|keeper|^mail|^www|^ns\d{0,2}\.|us$|uk$|cz$|ch$|sg$|ec$|nl$|au$|fi$|ca$|de$|kr$|tw$|it$|pl$|edu$|com$|org$|net$/i){ $proxy=1;} if($agent=~ /via|squid|delegate|httpd|proxy|cache/i){ $proxy=1;} if($host =~ /jp$/i){ $proxy=0;} if($xfor =~s/^(\d+)\.(\d+)\.(\d+)\.(\d+)(\D*).*/$1.$2.$3.$4/ ){ $proxy=0;} if($for =~s/.*\s(\d+)\.(\d+)\.(\d+)\.(\d+)/$1.$2.$3.$4/ ){ $proxy=0;} if($via =~s/.*\s(\d+)\.(\d+)\.(\d+)\.(\d+)/$1.$2.$3.$4/ ){ $proxy=0;} if($proxy eq '0'){ &who; } } sub who { print "Content-type: text/html\n\n"; print "へい、らっしゃい!!\n"; print "\n"; print "$body\n"; print "\n"; print "

\n"; print "

\n"; print "

調整中

\n"; print "

\n"; print "

\n"; print "
\n"; print "

written by 2代目怒羅絵悶

\n"; print "\n"; exit; }