 |
This site has
been visited #! /usr/bin/perl
$basedir = "/home/vhome/akmert/cgi-bin/log";
####################################################################
open (UNI,"$basedir/unique.log") || die print "can not find address";
$unique = ;
close UNI;
$unique_real = $ENV{'REMOTE_ADDR'};
####################################################################
# control unique
####################################################################
if (not($unique eq $unique_real)) {
open (UNI,">$basedir/unique.log") || die print "can not find address";
print UNI $unique_real;
close UNI;
open (NUMBER,"$basedir/counter.txt") || die print "can not find address";
$counter = ;
close NUMBER;
$no = int($counter) + 1;
open (NUMBER,">$basedir/counter.txt") || die print "can not find address";
print NUMBER $no;
close NUMBER;
&get_date;
open (DAYNUM,"$basedir/day_count.txt");
@DAYN = ;
close (DAYNUM);
foreach $line (@DAYN) { chop $line; }
if ($dat eq $DAYN[0]) {
$day_no = int($DAYN[1]) + 1;
open (DAYNUM,">$basedir/day_count.txt") || die print "can not find address";
flock DAYNUM, 2;
print DAYNUM "$DAYN[0]\n";
print DAYNUM"$day_no\n";
close (DAYNUM);
}
else
{
open (DAYSTAT,">>$basedir/day_stat.txt") || die print "can not find address";
print DAYSTAT "$DAYN[0] $DAYN[1]\n";
close DAYSTAT;
open (DAYNUM,">$basedir/day_count.txt") || die print "can not find address";
flock DAYNUM, 2;
print DAYNUM "$dat\n";
print DAYNUM"1\n";
close (DAYNUM);
}
print "Content-type: text/html\n\n";
print "$no\n";
####################################################################
# write info to LOG file
####################################################################
$log_value = $ENV{'REMOTE_ADDR'}." ".$date." ".$ENV{'REMOTE_HOST'}." ".$ENV{'HTTP_USER_AGENT'}."\n";
open (LOG,">>$basedir/counter.log") || die print "can not find address";
flock LOG, 2;
print LOG $log_value;
close LOG;
}
else
{
open (NUMBER,"$basedir/counter.txt") || die print "can not find address";
$counter = ;
close NUMBER;
print "Content-type: text/html\n\n";
print "$counter\n";
} ############## end if
exit;
####################################################################
# get date
####################################################################
sub get_date {
@days = ('Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday');
@months = ('January','February','March','April','May','June','July',
'August','September','October','November','December');
($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
$time = sprintf("%02d:%02d:%02d",$hour,$min,$sec);
$year += 1900;
$dat = sprintf("%02d/%02d/%02d",$mday,$mon+1,$year);
$date = "$dat $time";
}
times
|