#!/usr/bin/perl #上記は、サ−バ−のパスにあわせる。 #CGIの販売、転載、配布厳禁です。Ryuumu require "./logset.cgi"; if ($lock == 1) { open(LOCK, "$lockfile"); flock(LOCK, 2); } &jikan; if(defined ($ENV{'HTTP_REFERER'})){ if($ENV{'HTTP_REFERER'} ne ""){ open(IN,"$data") || die "Can't Open Count Data File\n"; while (){ ($referer,$no,$time2) = split(/\,/,$_); if($no > 900000){$no = 0;} if($ENV{'HTTP_REFERER'} eq $referer){$_ = "$referer\,".++$no."\,"."$time\n";$ok = 1;} push(@f,$_); if($. > $hoji){last;} } if($ok != 1){unshift(@f,"$ENV{'HTTP_REFERER'}\,1\,$time\n");} open(TMPA,">${mkbo}/temp$$") || die "Can't Open Count Data File\n"; chmod 0666, "${mkbo}/temp$$"; print TMPA @f; close(TMPA); close(IN); rename("${mkbo}/temp$$","$data"); #if (-e "${mkbo}/temp$$") { unlink("${mkbo}/temp$$"); } } } ########3 if(defined ($ENV{'HTTP_USER_AGENT'})){ if($ENV{'HTTP_USER_AGENT'} ne ""){ if($ENV{'HTTP_USER_AGENT'} =~ /.*((Mozilla\/ .)|(Mozilla\/.)).*/i){$mozilla = "$1\.0 ";$a = 1;} if($ENV{'HTTP_USER_AGENT'} =~ /.*((MSIE .)|(MSIE.)).*/i){$msie = "$1\.0 ";$a = 1;} if($ENV{'HTTP_USER_AGENT'} =~ /.*((Macintosh)|(Mac)).*/i){$bura = "$1 ";$a = 1;} elsif($ENV{'HTTP_USER_AGENT'} =~ /.*((Windows ..)|(Windows..)).*/i){$bura = "$1 ";$a = 1;} elsif($ENV{'HTTP_USER_AGENT'} =~ /.*((Win ..)|(Win..)).*/i){$bura = "$1 ";$a = 1;} if($ENV{'HTTP_USER_AGENT'} =~ /.*(proxy).*/i){$proxy = $1;$a = 1;} if($a != 1){$set = "$ENV{'HTTP_USER_AGENT'}";}else{ $set = "$mozilla$msie$bura$proxy"; } if(length($set) < 41){ open(INN,"$data2") || die "Can't Open Count Data File\n"; while (){ ($agent,$no,$time2) = split(/\,/,$_); if($no > 900000){$no = 0;} if($set eq $agent){$_ = "$agent\,".++$no."\,"."$time\n";$ok2 = 1;} push(@g,$_); if($. > $hoji2){last;} } if($ok2 != 1){unshift(@g,"$set\,1\,$time\n");} open(TMPP,">${mkbo}/tempb$$") || die "Can't Open Count Data File\n"; chmod 0666, "${mkbo}/tempb$$"; print TMPP @g; close(TMPP); close(INN); rename("${mkbo}/tempb$$","$data2"); #if (-e "${mkbo}/tempb$$") { unlink("${mkbo}/tempb$$"); } } } } ####### #unless ($ENV{'REMOTE_ADDR'} eq "" || $ENV{'REMOTE_HOST'} eq "") { $host = $ENV{'REMOTE_HOST'}; $addr = $ENV{'REMOTE_ADDR'}; if($hostsetup == 1) { $host = gethostbyaddr(pack('C4',split(/\./,$host)),2); }elsif($hostsetup == 2) { $host = gethostbyaddr(pack('C4',split(/\./,$addr)),2); }elsif($hostsetup == 3) {$host = "$addr";} if($host eq ""){$host = $addr;} if($host =~ /[a-zA-Z]/){ @host= split(/\./,$host); #shift(@host);$host = join(".",@host); @host = reverse(@host); if(@host >= 3){$host = "$host[2]\.$host[1]\.$host[0]";} else{$host = "$host[1]\.$host[0]";} } open(INM,"$data3") || die "Can't Open Count Data File\n"; while (){ ($host2,$no,$time2) = split(/\,/,$_); if($no > 900000){$no = 0;} if($host2 eq $host){$_ = "$host\,".++$no."\,"."$time\n";$ok3 = 1;} push(@h,$_); if($. > $hoji3){last;} } if($ok3 != 1){unshift(@h,"$host\,1\,$time\n");} open(TMPQ,">${mkbo}/tempc$$") || die "Can't Open Count Data File\n"; chmod 0666, "${mkbo}/tempc$$"; print TMPQ @h; close(TMPQ); close(INM); rename("${mkbo}/tempc$$","$data3"); #if (-e "${mkbo}/tempc$$") { unlink("${mkbo}/tempc$$"); } #} ################# 時間、週、月Logの書き込み &op; &countdec; open(TMP,">${mkbo}/tempd$$") || die "Can't Open Count Data File\n"; chmod 0666, "${mkbo}/tempd$$"; print TMP "$count\,$count2\,$counter\,$day\,$wday\,$mon\n"; #if($hour == 0){$hour = 24;} foreach (0..699){ if($lines[$_] eq ""){$lines[$_] = 0;$x = 1;} ### 時間 if($_ >= 0 && $_ <= 23){ #if($day != $day2 && $hour == $_){print TMP ++$lines[$_],"\n";}elsif($day != $day2 && $hour != $_){print TMP "0\n";} if($day != $day2 && $hour == $_){print TMP "1\n";}elsif($day != $day2 && $hour != $_){print TMP "0\n";} elsif($day == $day2 && $hour == $_ ){print TMP ++$lines[$_],"\n";}else{print TMP "$lines[$_]\n";} } if($_ > 23 && $_ <= 47){ if($day == $day2 || $x == 1){print TMP "$lines[$_]\n";} if($day != $day2 && $x != 1){print TMP "$lines[$_ - 24]\n";} } #### 曜日 &lineno; if($_ > 47 && $_ <= 54){ if(($wday eq '月' && $day != $day2 && $wday3 eq $wday) || ($x == 1 && $wday3 eq $wday)){print TMP "1\n";}elsif($wday eq '月' && $day != $day2 && $wday3 ne $wday){print TMP "0\n";} elsif($wday3 eq $wday){print TMP ++$lines[$_],"\n";}else{print TMP "$lines[$_]\n";} } if($_ > 54 && $_ <= 61){ if($wday eq '月' && $day != $day2){print TMP "$lines[$_ - 7]\n";} else{print TMP "$lines[$_]\n";} } #### 月 if($_ > 61 && $_ <= 92){ $day3++; if($mon2 != $mon && $day3 == $day){print TMP "1\n";}elsif($mon2 != $mon && $day3 != $day){print TMP "0\n";} if($mon2 == $mon && $day3 == $day){print TMP ++$lines[$_],"\n";}elsif($mon2 == $mon && $day3 != $day){print TMP "$lines[$_]\n";} } if($_ > 92 && $_ <= 123){ if($mon2 != $mon && $x != 1){print TMP "$lines[$_ - 31]\n";} else{print TMP "$lines[$_]\n";} } ######### 5分単位 if($_ > 123 && $_ <= 411){ if($_ > 123 && $_ <= 135){$c = 0;$d = 123;}if($_ > 135 && $_ <= 147){$c = 1;$d = 135;} if($_ > 147 && $_ <= 159){$c = 2;$d = 147;}if($_ > 159 && $_ <= 171){$c = 3;$d = 159;} if($_ > 171 && $_ <= 183){$c = 4;$d = 171;}if($_ > 183 && $_ <= 195){$c = 5;$d = 183;} if($_ > 195 && $_ <= 207){$c = 6;$d = 195;}if($_ > 207 && $_ <= 219){$c = 7;$d = 207;} if($_ > 219 && $_ <= 231){$c = 8;$d = 219;}if($_ > 231 && $_ <= 243){$c = 9;$d = 231;} if($_ > 243 && $_ <= 255){$c = 10;$d = 243;}if($_ > 255 && $_ <= 267){$c = 11;$d = 255;} if($_ > 267 && $_ <= 279){$c = 12;$d = 267;}if($_ > 279 && $_ <= 291){$c = 13;$d = 279;} if($_ > 291 && $_ <= 303){$c = 14;$d = 291;}if($_ > 303 && $_ <= 315){$c = 15;$d = 303;} if($_ > 315 && $_ <= 327){$c = 16;$d = 315;}if($_ > 327 && $_ <= 339){$c = 17;$d = 327;} if($_ > 339 && $_ <= 351){$c = 18;$d = 339;}if($_ > 351 && $_ <= 363){$c = 19;$d = 351;} if($_ > 363 && $_ <= 375){$c = 20;$d = 363;}if($_ > 375 && $_ <= 387){$c = 21;$d = 375;} if($_ > 387 && $_ <= 399){$c = 22;$d = 387;}if($_ > 399 && $_ <= 411){$c = 23;$d = 399;} if(($_ - $d) == 1){$e = 0;$b = 5;}if(($_ - $d) == 2){$e = 5;$b = 10;}if(($_ - $d) == 3){$e = 10;$b = 15;} if(($_ - $d) == 4){$e = 15;$b = 20;}if(($_ - $d) == 5){$e = 20;$b = 25;}if(($_ - $d) == 6){$e = 25;$b = 30;} if(($_ - $d) == 7){$e = 30;$b = 35;}if(($_ - $d) == 8){$e = 35;$b = 40;}if(($_ - $d) == 9){$e = 40;$b = 45;} if(($_ - $d) == 10){$e = 45;$b = 50;}if(($_ - $d) == 11){$e = 50;$b = 55;}if(($_ - $d) == 12){$e = 50;$b = 0;} if($day != $day2 && $min >= $e && $min < $b && $hour == $c){print TMP "1\n";}elsif(($day != $day2 && $hour == $c && !($min >= $e && $min < $b)) || ($day != $day2 && $hour != $c)){print TMP "0\n";} elsif($day == $day2 && $min >= $e && $min < $b && $hour == $c){print TMP ++$lines[$_],"\n";}else{print TMP "$lines[$_]\n";} } if($_ > 411 && $_ <= 699){ if($day == $day2 || $x == 1){print TMP "$lines[$_]\n";} if($day != $day2 && $x != 1){print TMP "$lines[$_ - 288]\n";} } ####### } close(TMP); rename("${mkbo}/tempd$$","$data4"); #if (-e "${mkbo}/tempd$$") { unlink("${mkbo}/tempd$$"); } if ($lock == 1) { flock(LOCK, 8); close(LOCK); } if($ssi eq 'on' && $play eq 'on'){ &counter; }elsif($ssi ne 'on'){ open(IMG,"$log") || die "Can't Open Count Data File\n"; @gif = stat("$log"); $byte = $gif[7]; print "Content-type: image/gif\n"; print "Content-length: $byte\n\n"; print ; close(IMG); } ################