%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/rappan/www/cgi_access/
Upload File :
Create Path :
Current File : //home/rappan/www/cgi_access/hana_indi.cgi

#!/usr/bin/perl

#******************************************************************************
#
# hana_indi.cgi - Access Analyzer
#
#Version   	:2.17
#modified  	:2002/01/08
#Copyright 	:The Room
#E-Mail		:dream@lib.net
#URL		:http://dream.lib.net/room/
#
#******************************************************************************
#1行目のperlのディレクトリ指定は、サーバによって異なります。
#詳しくは、管理者にお聞きください。
#******************************************************************************

srand;
require './hana_set.cgi';
require './hana_cmt.cgi';
require $lib_jcode;
&read_setting;
&read_setting_ref;
unshift(@set_data2,"top_トップページ");

$cl = $ENV{"CONTENT_LENGTH"};
if( $cl > 0 ){
	read(STDIN, $qs, $cl );
}else{
	$qs = $ENV{"QUERY_STRING"};
	}
@contents = split(/&/,$qs);

foreach $i (0 .. $#contents) {
	local($key,$text)= split(/=/,$contents[$i],2);
	$text =~ s/\+/ /g;
	$text =~ s/%(..)/pack("c",hex($1))/ge;
	$key =~ s/%(..)/pack("c",hex($1))/ge;
	$text =~ s/\r//g;
	$text =~ s/\n//g;
	if ($key eq 'indi12'){
		$list_indi12[$text]=1;
		}
	elsif ($key eq 'indi21'){
		$list_indi21{$text}=1;
		}else{
		$IN{$key}=$text;
		}
	}

if (($set_data1[5]) && ($IN{'pw'} ne $adminpass)){&enter;}

$a2 = $a3 = $a4 = "";
opendir(DIR,$dir_log);
while($a1 = readdir(DIR)){
	if ($a1 =~ /^(\d+)\.dat/){
		push(@log_file,$1);
		if ($IN{'indi10'} eq $1){$a2 = $IN{'indi10'};}
		if ($IN{'indi11'} eq $1){$a3 = $IN{'indi11'};}
		if ($IN{'indi31'} eq $1){$a4 = $IN{'indi31'};}
		}
	}
closedir(DIR);
@log_file = reverse(sort(@log_file));
$startflag = 1 if $IN{'datatype'} eq "";
$IN{'indi10'} = $log_file[0] if $a2 eq "";
$IN{'indi11'} = $log_file[0] if $a3 eq "";
$IN{'indi31'} = $log_file[0] if $a4 eq "";

$IN{'indi38'} = 1 if $IN{'indi39'};
$IN{'datatype'} = 0 if $IN{'datatype'} ne "0" && $IN{'datatype'} ne "1" && $IN{'datatype'} ne "2";
$IN{'indi11'} = $set_data1[0] if $IN{'indi11'} eq "" || $IN{'indi11'} =~ /[^\d]/ || $IN{'indi11'} < 1;
$IN{'indi17'} = 10 if $IN{'indi17'} eq "" || $IN{'indi17'} =~ /[^\d]/ || $IN{'indi17'} < 0;
$IN{'indi18'} = 5 if $IN{'indi18'} eq "" || $IN{'indi18'} =~ /[^\d]/ || $IN{'indi18'} < 0;
$IN{'indi24'} = $set_data1[1] if $IN{'indi24'} eq "" || $IN{'indi24'} =~ /[^\d]/ || $IN{'indi24'} < 0 || $IN{'indi24'} > $set_data1[1];
$IN{'indi26'} = $set_data1[2] if $IN{'indi26'} eq "" || $IN{'indi26'} =~ /[^\d]/ || $IN{'indi26'} < 0 || $IN{'indi26'} > $set_data1[2];
$IN{'indi32'} = 100 if $IN{'indi32'} eq "" || $IN{'indi32'} =~ /[^\d]/ || $IN{'indi32'} < 0;
if($set_data1[4]){$small1= "<small>";$small2="</small>";}

&head;
if ($startflag){
	#デフォルト設定
	$IN{'indi14'} = 4;
	$IN{'indi16'} = 1;
	foreach(22,23,25,33,34,35){$IN{'indi'.$_}=1;}
	foreach(0,1,2,3,6){$list_indi12[$_]=1;}
	foreach(@set_data2){$list_indi21{(split(/_/,$_,2))[0]}=1;}
	}
elsif ($IN{'datatype'} == 2){&indi2;}
elsif ($IN{'datatype'} == 1){&indi1;}
else{&indi0;}

&form;
&foot;

#******************************************************************************
sub indi1{
#アクセス数
my ($a1,$a2,$data_time,@temp1,@temp2);

$a1 = -1;
for(0 .. $#set_data2){
	@temp1 = split(/_/,$set_data2[$_],2);
	if ($list_indi21{$temp1[0]}){
		$a1++;
		$data[$a1][0] = $temp1[1];
		open(IN,"$dir_acs/$temp1[0].dat");
		eval{flock(IN,1)};
		@temp1 = split(/<>/,<IN>);$data[$a1][1]=$temp1[0];$data[$a1][4] = $temp1[3];
		@temp1 = split(/<>/,<IN>);$data[$a1][2]=([@temp1]);
		@temp1 = split(/<>/,<IN>);$data[$a1][3]=([@temp1]);
		close(IN);
		$data_time = $data[$a1][4] if $data[$a1][4] > $data_time;
		}
	}
# data_time を軸とした時間編集
for(0 .. $#data){
	next if $data[$_][4] == $data_time;
	$a1 = int($data_time/3600)-int($data[$_][4]/3600);
	if ($a1 != 0){for($i=1;$i<=$a1;$i++){unshift(@{$data[$_][2]},0);}}
	$a1 = int(($data_time+$area_time)/86400)-int(($data[$_][4]+$area_time)/86400);
	if ($a1 != 0){for($i=1;$i<=$a1;$i++){unshift(@{$data[$_][3]},0);}}
	}

print "<br><br><div align=center>アクセス数解析</div><br><br>";
if ($IN{'indi22'}){
	#累計アクセス数
	$a1 = $a2 = 0;
	for(0 .. $#data){$a2+=$data[$_][1];$a1 = $data[$_][1] if $data[$_][1] > $a1;}
	$cl = int(rand(1)*$#graph_list);
	print "<div align=center><b>累計アクセス数</b> - 有効データ $a2<br><br><table>";
	foreach(sort{$b->[1] <=> $a->[1];} @data){
		if ($a1 == 0){$a3 = 1;}
		else{$a3 = int(${$_}[1] / $a1 * $graph_width);$a3 = 1 if $a3 < 1;}

		print "<tr><td width=45% align=right><img src=\"$graph_list[$cl]\" height=8 width=$a3></td>";
		print "<td width=10% align=center nowrap>$small1${$_}[1] (".($a1?(int(${$_}[1]/$a2*10000)/100):"0")."%)$small2</td>";
		print "<td width=45% nowrap>$small1${$_}[0]$small2</td></tr>";
		}
	print "</table></div><br><br><br><br>";
	}

if ($IN{'indi23'}){
	#時間アクセス数
	$cl = int(rand(1)*$#color_list);

	print "<div align=center><b>時間別アクセス数</b> ($IN{'indi24'}時間)</div>";
	print "<br><table border=0 cellpadding=0 cellspacing=0 bgcolor=\"$color_list[$cl][0]\" align=center>";
	print "<tr><td><table border=0 width=100% cellpadding=3 cellspacing=1><tr><td>$small1時間$small2</td>";
	for(0 .. $#data){print "<td bgcolor=\"$color_list[$cl][1]\" nowrap align=right>$small1$data[$_][0]$small2</td>";}
	print "<td bgcolor=\"$color_list[$cl][1]\" nowrap align=right>$small1合計$small2</td>" if $#data > 0;
	print "</tr>";
	@temp2 = ();
	for(0 .. $IN{'indi24'}-1){
		@temp1 = gmtime($area_time+$data_time-$_*3600);
		printf "<tr><td bgcolor=\"$color_list[$cl][1]\">$small1%02d/%02d %02d時$small2</td>",$temp1[4]+1,$temp1[3],$temp1[2];
		$a1 = 0;
		for($i=0;$i<=$#data;$i++){
			$data[$i][2][$_] = 0 if $data[$i][2][$_] < 1;$a1+=$data[$i][2][$_];
			$temp2[$i]+=$data[$i][2][$_];
			print "<td bgcolor=\"$color_list[$cl][1]\" align=right>$small1$data[$i][2][$_]$small2</td>";
			}
		print "<td bgcolor=\"$color_list[$cl][1]\" align=right>$small1$a1$small2</td>" if $#data > 0;
		print "</tr>";
		}
	if ($IN{'indi24'} > 1){
		$a1 = 0;
		print "<tr><td bgcolor=\"$color_list[$cl][1]\" nowrap>$small1合計$small2</td>";
		for($i=0;$i<=$#data;$i++){
			$a1+=$temp2[$i];
			print "<td bgcolor=\"$color_list[$cl][1]\" align=right>$small1$temp2[$i]$small2</td>";
			}
		print "<td bgcolor=\"$color_list[$cl][1]\" align=right>$small1$a1$small2</td>" if $#data > 0;
		print "</tr>";
		$a1 = 0;
		print "<tr><td bgcolor=\"$color_list[$cl][1]\" nowrap>$small1平均$small2</td>";
		for($i=0;$i<=$#data;$i++){
			$temp2[$i] = int($temp2[$i]/$IN{'indi24'});$a1+=$temp2[$i];
			print "<td bgcolor=\"$color_list[$cl][1]\" align=right>$small1$temp2[$i]$small2</td>";
			}
		print "<td bgcolor=\"$color_list[$cl][1]\" align=right>$small1$a1$small2</td>" if $#data > 0;
		}
	print "</table></td></tr></table><br><br>";
	}

if ($IN{'indi25'}){
	#日別アクセス数
	$cl = int(rand(1)*$#color_list);

	print "<div align=center><b>日別アクセス数</b> ($IN{'indi26'}日間)</div>";
	print "<br><table border=0 cellpadding=0 cellspacing=0 bgcolor=\"$color_list[$cl][0]\" align=center>";
	print "<tr><td><table border=0 width=100% cellpadding=3 cellspacing=1><tr><td>$small1日付$small2</td>";
	for(0 .. $#data){print "<td bgcolor=\"$color_list[$cl][1]\" nowrap align=right>$small1$data[$_][0]$small2</td>";}
	print "<td bgcolor=\"$color_list[$cl][1]\" nowrap align=right>$small1合計$small2</td>" if $#data > 0;
	print "</tr>";
	@temp2 = ();
	for(0 .. $IN{'indi26'}-1){
		@temp1 = gmtime($area_time+$data_time-$_*86400);
		printf "<tr><td bgcolor=\"$color_list[$cl][1]\">$small1%02d/%02d$small2</td>",$temp1[4]+1,$temp1[3],$temp1[2];
		$a1 = 0;
		for($i=0;$i<=$#data;$i++){
			$data[$i][3][$_] = 0 if $data[$i][3][$_] < 1;$a1+=$data[$i][3][$_];
			$temp2[$i]+=$data[$i][3][$_];
			print "<td bgcolor=\"$color_list[$cl][1]\" align=right>$small1$data[$i][3][$_]$small2</td>";
			}
		print "<td bgcolor=\"$color_list[$cl][1]\" align=right>$small1$a1$small2</td>" if $#data > 0;
		print "</tr>";
		}
	if ($IN{'indi26'} > 1){
		$a1 = 0;
		print "<tr><td bgcolor=\"$color_list[$cl][1]\" nowrap>$small1合計$small2</td>";
		for($i=0;$i<=$#data;$i++){
			$a1+=$temp2[$i];
			print "<td bgcolor=\"$color_list[$cl][1]\" align=right>$small1$temp2[$i]$small2</td>";
			}
		print "<td bgcolor=\"$color_list[$cl][1]\" align=right>$small1$a1$small2</td>" if $#data > 0;
		print "</tr>";
		$a1 = 0;
		print "<tr><td bgcolor=\"$color_list[$cl][1]\" nowrap>$small1平均$small2</td>";
		for($i=0;$i<=$#data;$i++){
			$temp2[$i] = int($temp2[$i]/$IN{'indi26'});$a1+=$temp2[$i];
			print "<td bgcolor=\"$color_list[$cl][1]\" align=right>$small1$temp2[$i]$small2</td>";
			}
		print "<td bgcolor=\"$color_list[$cl][1]\" align=right>$small1$a1$small2</td>" if $#data > 0;
		}
	print "</table></td></tr></table><br><br>";
	}

if ($IN{'indi27'}){
	#曜日別アクセス数
	$cl = int(rand(1)*$#color_list);
	$a1 = (gmtime($area_time+$data_time))[6];
	$a2 = 0;
	@temp2 = ();
	while(1){
		$a1 = $a1 - 1 + ($a1 == 0)*7;
		$a2++;
		$a3 = 0;
		for(0 .. $#data){
			$a3+=$data[$_][3][$a2];
			$temp1[$_][$a1]+=$data[$_][3][$a2];
			}
		$temp2[$a1]++;
		last if $a3 == 0 || $a2 > 999;
		}
	$a2--;
	print "<div align=center><b>曜日別アクセス数</b> -  ($a2日間集計・今日のデータは除く)<br>カッコ内の値は平均値です。</div>";
	print "<br><table border=0 cellpadding=0 cellspacing=0 bgcolor=\"$color_list[$cl][0]\" align=center>";
	print "<tr><td><table border=0 width=100% cellpadding=3 cellspacing=1><tr><td>$small1曜日$small2</td>";
	for(0 .. $#data){print "<td bgcolor=\"$color_list[$cl][1]\" nowrap align=right>$small1$data[$_][0]$small2</td>";}
	print "<td bgcolor=\"$color_list[$cl][1]\" nowrap align=right>$small1合計$small2</td>" if $#data > 0;
	print "</tr>";

	@temp3 = ('日曜日','月曜日','火曜日','水曜日','木曜日','金曜日','土曜日');
	for(0 .. 6){
		print "<tr><td bgcolor=\"$color_list[$cl][1]\">$small1$temp3[$_]$small2</td>";
		$a1 = 0;
		for($i=0;$i<=$#data;$i++){
			$temp1[$i][$_] = 0 if $temp1[$i][$_] eq "";
			$a1+=$temp1[$i][$_];
			if ($temp2[$_] == 0){$a2=0;}else{$a2=int($temp1[$i][$_]/$temp2[$_]);}
			print "<td bgcolor=\"$color_list[$cl][1]\" align=right>$small1$temp1[$i][$_] ($a2)$small2</td>";			}
		if ($#data > 0){
			if ($temp2[$_] == 0){$a2=0;}else{$a2=int($a1/$temp2[$_]);}
			print "<td bgcolor=\"$color_list[$cl][1]\" align=right>$small1$a1 ($a2)$small2</td>";			}
		print "</tr>";
		}
	print "</table></td></tr></table><br><br>";
	}

}
#******************************************************************************
sub indi2{
#生ログ
my ($a1,@temp1,@log);

$a1 = 0;
if ($IN{'indi39'}){
	open(IN,"$dir_log/$IN{'indi31'}.dat");
	eval{flock(IN,1)};
	while(<IN>){push(@log,$_) if $_ =~ /\Q$IN{'indi39'}\E/;}
	close(IN);
	}else{
	open(IN,"$dir_log/$IN{'indi31'}.dat");
	eval{flock(IN,1)};
	@log=<IN>;
	close(IN);
	}
print "<br><br><div align=center>生ログ - ".substr($IN{'indi31'},0,4)."/".substr($IN{'indi31'},4,2)."/".substr($IN{'indi31'},6,2)." - $IN{'indi32'}件<br>";
print "(検索 - [$IN{'indi39'}])<br>" if $IN{'indi39'};
print "</div><br>";
$cl = int(rand(1)*$#color_list);
print "<table border=0 cellpadding=0 cellspacing=0 bgcolor=\"$color_list[$cl][0]\" align=center>";
print "<tr><td><table border=0 width=100% cellpadding=3 cellspacing=1><tr>";
print "<td nowrap bgcolor=\"$color_list[$cl][1]\">$small1アクセス時間$small2</td>" if $IN{'indi33'};
print "<td nowrap bgcolor=\"$color_list[$cl][1]\">$small1"."IP"."$small2</td>" if $IN{'indi34'};
print "<td nowrap bgcolor=\"$color_list[$cl][1]\">$small1ホスト名$small2</td>" if $IN{'indi35'};
print "<td nowrap bgcolor=\"$color_list[$cl][1]\">$small1ユーザーエージェント$small2</td>" if $IN{'indi36'};
print "<td nowrap bgcolor=\"$color_list[$cl][1]\">$small1リンク元$small2</td>" if $IN{'indi37'};
print "</tr><tr></tr>\n";
foreach(0 .. $IN{'indi32'}-1){
	last if $#log-$_ < 0;
	next if $log[$#log-$_] eq "";
	@temp1 = split(/<>/,$log[$#log-$_]);
	print "<tr>";
	if ($IN{'indi33'}){
		@temp2 = gmtime($area_time+$temp1[0]);
		printf "<td nowrap bgcolor=\"$color_list[$cl][1]\">$small1%02d/%02d %02d:%02d:%02d$small2</td>",$temp2[4]+1,$temp2[3],$temp2[2],$temp2[1],$temp2[0];
		}
	foreach $i(1,2,3){$temp1[$i]="(no data)" if $temp1[$i] eq "";}
	print "<td nowrap bgcolor=\"$color_list[$cl][1]\">$small1$temp1[1]$small2</td>" if $IN{'indi34'};
	print "<td nowrap bgcolor=\"$color_list[$cl][1]\">$small1$temp1[2]$small2</td>" if $IN{'indi35'};
	print "<td nowrap bgcolor=\"$color_list[$cl][1]\">$small1$temp1[3]$small2</td>" if $IN{'indi36'};
	print "<td nowrap bgcolor=\"$color_list[$cl][1]\">$small1".($temp1[7]?"<a href=\"$temp1[7]\" target=\"_blank\">$temp1[7]</a>":"(no data)")."$small2</td>" if $IN{'indi37'};
	print "</tr>\n";
	}
print "</table></td></tr></table><br><br>";


}
#******************************************************************************
sub indi0{
#ログ解析
my ($a1,$a2,$a3,$cl,$buf,$i,$j,@temp1);
my ($file,$file_num,$file_list);
for(0 .. 11){$data2[$_] = 0;}

if ($IN{'indi10'} > $IN{'indi11'}){
	$a1 = $IN{'indi10'};
	$IN{'indi10'} = $IN{'indi11'};
	$IN{'indi11'} = $a1;
	}

foreach $file(@log_file){
	next if $file < $IN{'indi10'} || $file > $IN{'indi11'};
	open(IN,"$dir_log/$file.dat");
	while(<IN>){
		@temp1 = split(/<>/,$_);

		if (($temp1[7]) && ($list_indi12[7]) || ($list_indi12[8])){
#検索エンジンチェック
$a2 = "";
if ($temp1[7] =~ /^http:\/\/kensaku\.jp\/.*?key=([^\&]*)/i){$a2 = $1;$data[7]{'kensaku.jp'}++;}
elsif ($temp1[7] =~ /^http:\/\/search\.goo\.ne\.jp\/.*?MT=([^\&]*)/i){$a2 = $1;$data[7]{'goo'}++;}
elsif ($temp1[7] =~ /^http:\/\/www\.tocc\.co\.jp\/.*?QRY=([^\&]*)/i){$a2 = $1;$data[7]{'TOCC/Search'}++;}
elsif (($temp1[7] =~ /^http:\/\/www\.google\..*?q=([^\&]*)/i) && ($1 !~ /^cache:/i)){$a2 = $1;$data[7]{'google'}++;}
elsif ($temp1[7] =~ /^http:\/\/www\.excite\.co\.jp\/.*?search=([^\&]*)/i){$a2 = $1;$data[7]{'excite'}++;}
elsif ($temp1[7] =~ /^http:\/\/www\.alltheweb\.com\/.*?query=([^\&]*)/i){$a2 = $1;$data[7]{'alltheweb'}++;}
elsif ($temp1[7] =~ /^http:\/\/odin\.ingrid\.org\/.*?key=([^\&]*)/i){$a2 = $1;$data[7]{'ODiN'}++;}
elsif ($temp1[7] =~ /^http:\/\/www\.infoseek\.co\.jp\/.*?qt=([^\&]*)/i){$a2 = $1;$data[7]{'InfoSeek'}++;}
elsif ($temp1[7] =~ /^http:\/\/search\.naver\.co\.jp\/.*?query=([^\&]*)/i){$a2 = $1;$data[7]{'Naver'}++;}
elsif ($temp1[7] =~ /^http:\/\/www\.altavista\.com\/.*?q=([^\&]*)/i){$a2 = $1;$data[7]{'AltaVista'}++;}
elsif ($temp1[7] =~ /^http:\/\/www\.lycos\.co\.jp\/.*?query=([^\&]*)/i){$a2 = $1;$data[7]{'Lycos'}++;}
elsif ($temp1[7] =~ /^http:\/\/search\.fresheye\.com\/.*?kw=([^\&]*)/i){$a2 = $1;$data[7]{'FreshEye'}++;}
elsif ($temp1[7] =~ /^http:\/\/search\.mycom\.co\.jp\/.*?a1=([^\&]*)/i){$a2 = $1;$data[7]{'GotCha'}++;}
elsif ($temp1[7] =~ /^http:\/\/search\.yahoo\.co\.jp\/.*?p=([^\&]*)/i){$a2 =$1;$data[7]{'Yahoo!Japan'}++;}
elsif ($temp1[7] =~ /^http:\/\/google\.yahoo\.co\.jp\/.*?p=([^\&]*)/i){$a2 =$1;$data[7]{'Yahoo!Japan'}++;}
elsif ($temp1[7] =~ /^http:\/\/search\.msn\.co\.jp\/.*?q=([^\&]*)/i){$a2 = $1;$data[7]{'MSN'}++;}
elsif ($temp1[7] =~ /^http:\/\/dir\.isize\.com\/.*?QueryString=([^\&]*)/i){$a2 = $1;$data[7]{'ISIZE'}++;}
elsif ($temp1[7] =~ /^http:\/\/allabout\.co\.jp\/.*?qs=([^\&]*)/i){$a2= $1;$data[7]{'All About Japan'}++;}
elsif ($temp1[7] =~ /^http:\/\/cgi\.search\.biglobe\.ne\.jp\/.*?q=([^\&]*)/i){$a2 = $1;$data[7]{'BIGLOBEサーチ'}++;}
elsif ($temp1[7] =~ /^http:\/\/inetg\.com\/.*?key=([^\&]*)/i){$a2 = $1;$data[7]{'iNET Guide'}++;}
elsif ($temp1[7]=~ /^http:\/\/para\.cab\.infoweb\.ne\.jp.*?Querystring=([^\&]*)/i){$a2=$1;$data[7]{'InfoNavigator'}++;}
if ($a2){
	$a2 =~ s/\+/ /g;
	$a2 =~ s/%(..)/pack("c",hex($1))/ge;
	&jcode::convert(\$a2,'sjis');
	$data2[7]++;
	if ($IN{'indi19'}){
		$a2 =~ s/"//g;$a2 =~ s/ / /g;$a2 =~ s/,/ /g;$a2 =~ s/ +/ /g;
		foreach $i(split(/ /,$a2)){
			next if $i eq "";
			$i = uc($i) if $IN{'indi19'} && $i !~ /[^\w]/;
			$data[8]{$i}++;$data2[8]++;
			}
		}else{
		$data[8]{$a2}++;$data2[8]++;
		}
	}
}

		#ホスト名
		if (($list_indi12[0]) && ($temp1[2])){
			if ($IN{'indi13'}){
				if ($temp1[2] =~ /(\.[a-z]+)$/i){
					$data[0]{lc($1)}++;
					$data2[0]++;
					}
				}else{
				#最後3つのみ取り出す。
				$temp1[2] = "***.".$1 if ($temp1[2] !~ /\d+\.\d+\.\d+\.\d+/) && ($temp1[2] =~ /([^\.]+\.[^\.]+\.[^\.]+)$/);
				$data[0]{$temp1[2]}++;
				$data2[0]++;
				}
			}
		#リファラー
		if (($list_indi12[1]) && ($temp1[7])){
			if($IN{'indi14'} == 4){
				$temp1[7] =~ s/\?.*//g;
				foreach $i(@ref_url){
					if ($temp1[7] =~ /\Q$i\E/i){
						$temp1[7] = $i;last;
						}
					}
				}
			elsif ($IN{'indi14'} == 3){
				if ($temp1[7] =~ /^http:\/\/.*?(\.[^\.|\/|\d]+)\//i){
					$temp1[7]=$1;
					}else{
					$temp1[7]="";
					}
				}
			elsif ($IN{'indi14'} == 2){
				 if ($temp1[7] =~ /^http:\/\/(.*?)\//i){
					$temp1[7]=$1;
					}else{
					$temp1[7]="";
					}
				}
			elsif ($IN{'indi14'} == 1){
				$temp1[7] =~ s/\?.*//g;
				}
			if ($temp1[7]){$data[1]{$temp1[7]}++;$data2[1]++;}
			}
		#ブラウザ
		if (($temp1[6]) && ($list_indi12[2])){
			if ($IN{'indi15'} == 11){
				if ($temp1[6] =~ /Internet Explorer/){
					$data[2]{'IE'}++;
					$data[11]{$temp1[6]}++;$data2[11]++;
					}
				elsif ($temp1[6] =~ /Netscape/){
					$data[2]{'NN'}++;
					$data[12]{$temp1[6]}++;$data2[12]++;
					}else{
					$data[2]{'Other'}++;
					}
				$data2[2]++;
				}
			elsif (($IN{'indi15'} == 0) || ($temp1[5] == $IN{'indi15'}-1)){
				if ($temp1[6] =~ /Internet Explorer (\d+)\./){
					$temp1[6] = "Internet Explorer $1.x";}
				elsif ($temp1[6] =~ /Netscape Navigator (\d+)\./){
					$temp1[6] = "Netscape Navigator $1.x";}

				$data[2]{$temp1[6]}++;
				$data2[2]++;
				}
			}
		#OS
		if (($temp1[4]) && ($list_indi12[3])){$data[3]{$temp1[4]}++;$data2[3]++;}
		#画面解像度
		if (($temp1[8]) && ($list_indi12[4])){$data[4]{$temp1[8]}++;$data2[4]++;}
		#画面発色数
		if (($temp1[9]) && ($list_indi12[5])){$data[5]{$temp1[9]}++;$data2[5]++;}
		#訪問回数
		if (($temp1[12]) && ($list_indi12[6])){$data[6]{$temp1[12]}++;$data2[6]++;}
		#タイムゾーン
		if (($temp1[11]) && ($list_indi12[9])){$data[9]{$temp1[11]}++;$data2[9]++;}
		#言語環境
		if (($temp1[10]) && ($list_indi12[10])){$data[10]{$temp1[10]}++;$data2[10]++;}
		}
	close(IN);
	}

print "<div align=center>ログ解析 - ".substr($IN{'indi10'},0,4)."/".substr($IN{'indi10'},4,2)."/".substr($IN{'indi10'},6,2)." 〜 ".substr($IN{'indi11'},0,4)."/".substr($IN{'indi11'},4,2)."/".substr($IN{'indi11'},6,2)."</div><br><br>\n\n";

@temp1 = ('ホスト名','リンク元','ブラウザ(エージェント)','OS','画面解像度','画面発色数','訪問回数','検索エンジン','検索ワード','アクセス元タイムゾーン','アクセス元言語環境');
for(0..10){
	if ($list_indi12[$_]){
		$cl = int(rand(1)*$#graph_list);
		print "<div align=center><b>$temp1[$_]</b> -";
		if (($_ == 0) && ($IN{'indi13'})){print " <b>国別</b> -";}
		elsif ($_ == 1){
			if ($IN{'indi14'} == 1){print " <b>引数削除</b> -";}
			elsif ($IN{'indi14'} == 2){print " <b>ドメイン別</b> -";}
			elsif ($IN{'indi14'} == 3){print " <b>国別</b> -";}
			elsif ($IN{'indi14'} == 4){print " <b>サイト名表\示</b> -";}
			}
		elsif ($_ == 2){
			if ($IN{'indi15'} == 1){print " <b>ブラウザ</b> -";}
			elsif ($IN{'indi15'} == 2){print " <b>ロボット・巡回ソ\フト</b> -";}
			elsif ($IN{'indi15'} == 10){print " <b>その他</b> -";}
			elsif ($IN{'indi15'} == 11){print " <b>IE/NNシェア</b> -";}
			}
		elsif ($_ == 8){
			if ($IN{'indi19'} == 1){print " <b>単語集計</b> -";}
			elsif ($IN{'indi19'} == 2){print " <b>単語集計(大小文字区別なし)</b> -";}
			}

		print " 有効データ数 $data2[$_]<br><br>";
		if (($_ == 2) && ($IN{'indi15'} == 11)){
			#シェア
			$temp1[2] = '全体比';$temp1[11] = 'バージョン比 (IE)';$temp1[12]='バージョン比 (NN)';
			foreach $j(2,11,12){
				$a1 = "";
				$a2 = 0;
				print "<b>$temp1[$j]</b><br><br><table width=100%>";
				foreach $i(sort{$data[$j]{$b} <=> $data[$j]{$a};} keys %{$data[$j]}){
					$a2++;
					last if (($a2 > $IN{'indi17'}) && ($IN{'indi16'} == 1)) || (($data[$j]{$i} <= $IN{'indi18'}) && ($IN{'indi16'} == 2)) && $j != 2;
					$a1 = $data[$j]{$i} if $a1 eq "";
					if ($a1 == 0){$a3=1;}
					else{$a3 = int($data[$j]{$i}/$a1*$graph_width);$a3=1 if $a3 == 0;}
					print "<tr><td align=right width=45%><img src=\"$graph_list[$cl]\" height=8 width=$a3</td>";
					print "<td align=center width=10% nowrap>$small1$data[$j]{$i} (".($data2[$j]?(sprintf("%02.2f",$data[$j]{$i}/$data2[$j]*100)):"0")."%)$small2</td>";
					print "<td align=left width=45% nowrap>$small1$i</small></td></tr>";
					}
				print "</table><br><br>";
				}
			print "</div><br><br>";
			}else{
			$a1 = "";
			$a2 = 0;
			print "<table width=100%>";
			foreach $i(sort{$data[$_]{$b} <=> $data[$_]{$a};} keys %{$data[$_]}){
				$a2++;
				last if (($a2 > $IN{'indi17'}) && ($IN{'indi16'} == 1)) || (($data[$_]{$i} <= $IN{'indi18'}) && ($IN{'indi16'} == 2));
				$a1 = $data[$_]{$i} if $a1 eq "";
				if ($a1 == 0){$a3=1;}
				else{$a3 = int($data[$_]{$i}/$a1*$graph_width);$a3=1 if $a3 == 0;}
				print "<tr><td align=right width=45%><img src=\"$graph_list[$cl]\" height=8 width=$a3</td>";
				print "<td align=center width=10% nowrap>$small1$data[$_]{$i} (".($data2[$_]?(sprintf("%02.2f",$data[$_]{$i}/$data2[$_]*100)):"0")."%)$small2</td>";
				print "<td align=left width=45% nowrap>$small1";
				if (($_ == 1) && ($IN{'indi15'} != 2) && ($IN{'indi15'} != 3)){
					print "<a href=\"$i\" target=\"_blank\">".&length_check(($ref_name{$i}?$ref_name{$i}:$i))."</a>";
#					}
#				elsif ($_ == 8){
#					$a3 = $i;
#					$a3 =~ s/\+/ /g;
#					$a3 =~ s/%(..)/pack("c",hex($1))/ge;
#					&jcode::convert(\$a3,'sjis');
#					print &length_check($a3);
					}else{
					print &length_check($i);
					}
				if (($cmt{'dom'}{$i}) && ((($_ == 0) && ($IN{'indi13'})) || ($_ == 1) && ($IN{'indi14'} == 3))){print " (".$cmt{'dom'}{$i}.")";}
				elsif ($_ == 5){print "ビット";print " (".$cmt{'cl'}{$i}.")" if $cmt{'cl'}{$i};}
				elsif ($_ == 6){print "回";}
				elsif ($_ == 9){print "分";print " (".$cmt{'tz'}{$i}.")" if $cmt{'tz'}{$i};}
				elsif ($_ == 10){
					if($cmt{'lang'}{$i}){print " (".$cmt{'lang'}{$i}.")";}
					elsif ($i =~ /-/){
						$a3 = (split(/-/,$i))[0];
						if($cmt{'lang'}{$a3}){print " (".$cmt{'lang'}{$a3}.")";}
						}
					}
				print "$small2</td></tr>\n";
				}
			print "</table></div><br><br><br><br>";
			}
		}
	}
print "<br><br>";
return;
}
#******************************************************************************
sub form{
#表示フォーム
my @check;
my @temp1 = ('ホスト名','リンク元','ブラウザ(エージェント)','OS','画面解像度','画面発色数','訪問回数','検索エンジン','検索ワード','アクセス元タイムゾーン','アクセス元言語環境');

$check[0][$IN{'datatype'}] = " checked";
$check[1][$IN{'indi13'}] = " selected";
$check[2][$IN{'indi14'}] = " selected";
$check[3][$IN{'indi15'}] = " selected";
$check[4][$IN{'indi16'}] = " checked";
$check[5][$IN{'indi19'}] = " selected";

print <<EOD;
<form method="post" action="./hana_indi.cgi"><table align=center><tr>
<td bgcolor=#c0c0e0 align=center><input type="radio" name="datatype" value="0"$check[0][0]>ログ解析</td>
<td bgcolor=#e0c0c0 align=center><input type="radio" name="datatype" value="1"$check[0][1]>アクセス数</td>
<td bgcolor=#c0e0c0 align=center><input type="radio" name="datatype" value="2"$check[0][2]>生ログ</td>
</tr>
<tr><td valign=top bgcolor=#d0d0e0>
<table><tr><td valign=top colspan=2>
集計期間 <select name="indi10">
EOD
foreach(@log_file){
	print "<option value=\"$_\"";
	print " selected" if $_ eq $IN{'indi10'};
	print ">".substr($_,0,4)."/".substr($_,4,2)."/".substr($_,6,2);
	}
print "</select> 〜 <select name=\"indi11\">";
foreach(@log_file){
	print "<option value=\"$_\"";
	print " selected" if $_ eq $IN{'indi11'};
	print ">".substr($_,0,4)."/".substr($_,4,2)."/".substr($_,6,2);
	}
print <<EOD;
</select>
</td></tr>
<tr><td valign=top>
表\示データ<br>
<select name="indi12" multiple size=11>
EOD
for(0 .. 10){
	print "<option value=\"$_\"";
	print " selected" if $list_indi12[$_];
	print ">$temp1[$_]\n";
	}
print <<EOD;
</select><br>
</td><td valign=top>
ホスト名オプション<br>
<select name="indi13">
<option value="0"$check[1][0]>通常
<option value="1"$check[1][1]>国別
</select><br><br>
リンク元オプション<br>
<select name="indi14">
<option value="0"$check[2][0]>通常
<option value="1"$check[2][1]>引数削除
<option value="4"$check[2][4]>サイト名表\示
<option value="2"$check[2][2]>ドメイン別
<option value="3"$check[2][3]>国別
</select><br>
<br>
ブラウザオプション<br>
<select name="indi15">
<option value="0"$check[3][0]>全種類表\示
<option value="11"$check[3][11]>IE/NNシェア
<option value="1"$check[3][1]>ブラウザ
<option value="2"$check[3][2]>ロボット・巡回ソ\フト
<option value="10"$check[3][10]>その他
</select><br>
<br>
検索ワードオプション<br>
<select name="indi19">
<option value="0"$check[5][0]>通常
<option value="1"$check[5][1]>単語集計
<option value="2"$check[5][2]>単語集計(大小文字区別なし)
</select><br>
</td></tr>
<tr><td colspan=2 valign=top>
表\示制限<br>
<input type="radio" name="indi16" value="0"$check[4][0]>無制限<br>
<input type="radio" name="indi16" value="1"$check[4][1]>
上位 <input type="text" name="indi17" value="$IN{'indi17'}" size=3> 件を表\示<br>
<input type="radio" name="indi16" value="2"$check[4][2]>
データ数が <input type="text" name="indi18" value="$IN{'indi18'}" size=2>個以下の項目は非表\示<br>
</td></tr>
</table>

</td>
<td valign=top bgcolor=#e0d0d0>
<table><tr><td>
表\示ページ<br>
<select name="indi21" multiple size=6>
EOD
for(0 .. $#set_data2){
	@temp1 = split(/_/,$set_data2[$_],2);
	print "<option value=\"$temp1[0]\"";
	print " selected" if $list_indi21{$temp1[0]};
	print ">$temp1[1]\n";
	}
print "</select><br><br>";
print "<input type=\"checkbox\" name=\"indi22\" value=\"1\"".($IN{'indi22'}?" checked":"").">累計<br>\n";
print "<input type=\"checkbox\" name=\"indi23\" value=\"1\"".($IN{'indi23'}?" checked":"").">";
print "時間別 - <input type=\"text\" name=\"indi24\" value=\"$IN{'indi24'}\" size=2>時間<br>\n";
print "<input type=\"checkbox\" name=\"indi25\" value=\"1\"".($IN{'indi25'}?" checked":"").">";
print "日別 - <input type=\"text\" name=\"indi26\" value=\"$IN{'indi26'}\" size=2>日間<br>\n";
print "<input type=\"checkbox\" name=\"indi27\" value=\"1\"".($IN{'indi27'}?" checked":"").">曜日別\n";
print "</td></tr></table>\n</td>\n<td bgcolor=#d0e0d0 valign=top>\n<table><tr><td>\n表\示日\n<select name=\"indi31\">";
foreach(@log_file){
	print "<option value=\"$_\"";
	print " selected" if $_ eq $IN{'indi31'};
	print ">".substr($_,0,4)."/".substr($_,4,2)."/".substr($_,6,2);
	}
print "</select><br>\n表\示件数\n<input type=\"text\" name=\"indi32\" value=\"$IN{'indi32'}\" size=4>件<br><br>\n";
print "<input type=\"checkbox\" name=\"indi33\" value=\"1\"".($IN{'indi33'}?" checked":"").">アクセス時間<br>\n";
print "<input type=\"checkbox\" name=\"indi34\" value=\"1\"".($IN{'indi34'}?" checked":"").">IP<br>\n";
print "<input type=\"checkbox\" name=\"indi35\" value=\"1\"".($IN{'indi35'}?" checked":"").">ホスト名<br>\n";
print "<input type=\"checkbox\" name=\"indi36\" value=\"1\"".($IN{'indi36'}?" checked":"").">ユーザーエージェント<br>\n";
print "<input type=\"checkbox\" name=\"indi37\" value=\"1\"".($IN{'indi37'}?" checked":"").">リンク元<br>\n";
print "<input type=\"checkbox\" name=\"indi38\" value=\"1\"".($IN{'indi38'}?" checked":"").">検索 - ";
print "<input type=\"text\" name=\"indi39\" value=\"$IN{'indi39'}\" size=12><br>\n";
print <<EOD;
</td></tr></table>
</td>
</tr>
<tr><td colspan=3 align=center><input type="submit" value="     データ表\示      "><br><br></td></tr>
<tr><td colspan=3>
<small>
*セレクトボックスは CTRLキー(Win)/COMMANDキー(MAC) を使うと複数選択が出来ます。<br>
*リンク元オプションの「引数削除」は、URLの ? 以降のデータを取り除いて集計を行います。<br>
*「サイト名表\示」は、引数削除を行った後に、内部で登録してあるURLをサイト名に変換して表\示します。<br>
</small>
</td></tr>

</table>
<input type="hidden" name="pw" value="$IN{'pw'}">
</form>
EOD
}
#******************************************************************************
sub head{
#ヘッダ
print "Content-type:text/html; charset=shift_jis\n\n";
print <<EOD;
<html lang="ja">
<head>
<meta http-equiv="content-type" content="text/html; charset=shift_jis">
<title>Access Analyzer</title>
<style type="text/css">
<!--
a:hover{color:#808080;}

-->
</style>
</head>
<body bgcolor=#ffffff text=#000000 link=#000000 vlink=#000000 alink=#808080>
<b>Access Analyzer</b><br><br>
EOD
}
#******************************************************************************
sub foot{
print <<EOD;
<br>
<div align=center>
<a href="http://dream.lib.net/room/" target="_blank">Accese Analyzer by The Room</a>
<!--著作権表\示を削除することを禁じます。-->
</div><br>
<br>
</body></html>
EOD
}
#**************************************************************************
sub enter{
&head;
print <<EOD;
<table width=95% align=center>
<tr><td bgcolor=#d0d0e0>認証</td></tr>
<tr><td><br>
<form method="post" action="./hana_indi.cgi">
ログの閲覧には認証が必要です。<br>
<br>
パスワード
<input type="password" name="pw" value="" size=8>
<input type="submit" value="認証">
</form>
<br>
</td></tr>
<tr><td bgcolor=#d0d0e0 align=right>認証</td></tr>
</table><br>
EOD
&foot;
exit;
}
#**************************************************************************
sub length_check{
my $a1 = shift;
#$a1 = $ref_name{$a1} if $ref_name{$a1};
if (length($a1) > $set_data1[3]){return substr($a1,0,$set_data1[3])."...";}
else{return $a1;}
}
#**************************************************************************
sub read_setting_ref{
my @temp1;
open(IN,$file_ref);
while(<IN>){
	chomp;
	@temp1 = split(/\t/,$_);
	push(@ref_url,$temp1[1]);
	$ref_name{$temp1[1]}=$temp1[0];
	}
close(IN);
}
#*****************************************************************************

Zerion Mini Shell 1.0