#!/usr/bin/perl # count.cgi # シンプルな画像式カウンタ # Copyright(C) Satsuki (OrangeRemix) # # 2003.01.04 Ver 1.0 # 2004.11.01 Ver 1.01 プチ変更(書式等) use strict; use vars qw ($DATA $LENGTH $IMG $IPCHECK); require './gifcat.pl'; ########### 環境設定 ########################################## $DATA = "./count.dat"; # カウントファイル名 $LENGTH = 6; # 表示桁数 $IMG = "./image"; # 0.gif〜9.gifの入ったディレクトリのパス $IPCHECK = 1; # 同一IPからの連続アクセスをチェック (0:カウントする, 1:カウントしない) ############################################################### &main(); exit; #============================================================== sub main () { my ($count, $iplog, $datelog, $zero, @c) = (); my $ip = $ENV{'REMOTE_ADDR'}; my $date = &getdate(); open (FILE, "+<$DATA"); flock (FILE, 2); my $tmp = ; ($count, $iplog, $datelog) = split (/,/, $tmp); unless ($IPCHECK and $ip eq $iplog and $date eq $datelog) { $count++; } truncate(FILE,0); seek(FILE,0,0); print FILE "$count,$ip,$date"; close (FILE); if (length ($count) < $LENGTH) { $zero = "0"; $zero x= ($LENGTH - length($count)); $count = "$zero$count"; } @c = split (//, $count); foreach (@c) { $_ = "$IMG/$_.gif"; } binmode (STDOUT); print "Content-type: image/gif\n\n"; print &gifcat'gifcat(@c); } sub getdate () { my ($sec, $min, $hour, $day, $mon, $year, $wday, $yday, $isdst) = localtime(); $year += 1900; $mon++; $day = "0$day" if $day < 10; $mon = "0$mon" if $mon < 10; my $ret = $year . $mon . $day; return $ret; }