#!/usr/local/bin/perl
#print "HTTP/1.0 200 OK\n";
#@ARGV = "../_private";
################################################
# Web Page Access Counter
# Perl control script (cnt.pl)
# Programming and concept by Larry Sherman
# (c)1996 Computerrific
# 2/16/96
# http://www.computerrific.com/cory/show.htm
################################################
#
# SCRIPT MODIFICATION
# Modify the first line of this script if your Perl executable is
# located in a different directory than '/usr/local/bin/'.
#
# SCRIPT INSTALLATION and WEB PAGE MODIFICATION
# Operation of this counter requires three files:
# cnt.pl (this CGI script)
# cnt.val (support file 1)
# pix.dat (support file 2)
#
# If your service provider requires that CGI scripts be run from a
# special subdir (such as 'cgi-bin') below your 'public_html' dir, move
# all three files into that subdir. In your web page, add an HTML
# tag which points to this script. For example:
#
#
# If CGI scripts must be run from a SYSTEM 'cgi_bin', an absolute path
# to the script may be required. For example:
#
#
# If your system allows CGI scripts with '.cgi' extensions to be run
# from any directory, rename this script to 'cnt.cgi' and leave all three
# files in the CORY directory. In your web page, add this
tag:
#
#
# NOTE FROM THE AUTHOR
# I program in 'C'. I am NOT a Perl programmer. This code may not be
# pretty, but it works. I studied just enough Perl to accomplish this
# task. Please do not flood me with advice on how to clean up this script.
# Thanks.
#
########## Do NOT modify beyond here ###########
if(@ARGV ==0){
$cntdir= ".";
}else{
$cntdir= $ARGV[0];
}
@Msk70=
(1,1,1,1,1,1,0,
0,1,1,0,0,0,0,
1,1,0,1,1,0,1,
1,1,1,1,0,0,1,
0,1,1,0,0,1,1,
1,0,1,1,0,1,1,
1,0,1,1,1,1,1,
1,1,1,0,0,0,0,
1,1,1,1,1,1,1,
1,1,1,1,0,1,1);
@MskDM=
(0x7C,0xA2,0x92,0x8A,0x7C,
0x02,0x02,0xFE,0x42,0x02,
0x62,0x92,0x92,0x8A,0x46,
0x6C,0x92,0x92,0x82,0x44,
0x10,0xFE,0x10,0x10,0xF0,
0x8C,0x92,0x92,0x92,0xF4,
0x0C,0x92,0x92,0x92,0x7C,
0xC0,0xA0,0x90,0x8E,0x80,
0x6C,0x92,0x92,0x92,0x6C,
0x7C,0x92,0x92,0x92,0x60);
if(!open(FILE,"$cntdir/pix.dat")){
&error;
print "open pix.dat\n
";
exit(1);
}
binmode(FILE);
read(FILE,$Hdr,8);
read(FILE,$Xon,3);
read(FILE,$Xoff,3);
$FG=unpack("\@2C",$Hdr);
read(FILE,$Head,13+3);
$d36=unpack("\@4C",$Hdr);
if($FG==13){
seek(FILE,$d36*21,1);
}else{
seek(FILE,($d36*126)-21,1);
}
@Buff=;
close(FILE);
$PW=unpack("\@7C",$Hdr)*256+unpack("\@6C",$Hdr);
if(!open(FILE,"$cntdir/cnt.val")){
&error;
print "open cnt.val (r)\n
";
exit(1);
}
$Cnt=;
close(FILE);
if($ARGV[0]==$PW){
$Cnt=$ARGV[1]+0;
}else{
$Cnt+=1;
}
if($Cnt>999999){$Cnt=1;}
if(!open(FILE,">$cntdir/cnt.val")){
&error;
print "open cnt.val (w)\n
";
exit(1);
}
print FILE $Cnt;
close(FILE);
$Num[5]=int($Cnt/100000);$Cnt%=100000;
$Num[4]=int($Cnt/10000);$Cnt%=10000;
$Num[3]=int($Cnt/1000);$Cnt%=1000;
$Num[2]=int($Cnt/100);$Cnt%=100;
$Num[1]=int($Cnt/10);
$Num[0]=$Cnt%10;
print "Content-type: image/gif\n\n";
print $Head;
if($FG==13){
for($d05=0;$d05<$d36;$d05++){
$Ptr70=$Num[$d05]*7+$Msk70;
for($seg=0;$seg<7;$seg++) {
if($Msk70[$Ptr70+$seg] == 1){
print $Xon;
}else{
print $Xoff;
}
}
}
}else{
for($d05=0;$d05<$d36;$d05++){
$d09=$Num[$d05];
for($col=0;$col<5;$col++){
$mbyte=$MskDM[($d09*5)+$col];
for($row=0;$row<7;$row++){
if($mbyte<0x80){
print $Xoff;
}else{
print $Xon;
}
$mbyte= ($mbyte & 0x7F)<<1;
}
}
if($d05 != $d36-1){
for($x=0;$x<7;$x++){ print $Xoff;}
}
}
}
print @Buff;
sub error{
print "Content-type: text/html\n\n
\nError: ";
}