#! /usr/bin/perl # Counter Script Version 1.1.0 # Created by Robert Thomitzek 101763.1434@comuserve.com # Created on: 4.7.97 Last Modified on: 4.7.97 ####################################################################### # Define Variables ### FILE AND DIRECTORY LOCATIONS, REFERERS ### $pcount = "0"; $count_file = "acc.cnt"; $access_log = "access.log"; $error_log = "error.log"; $key = "acc"; $bitmap0[0] = "0xff"; $bitmap1[0] = "0xff"; $bitmap2[0] = "0xff"; $bitmap3[0] = "0xc3"; $bitmap4[0] = "0x99"; $bitmap5[0] = "0x99"; $bitmap6[0] = "0x99"; $bitmap7[0] = "0x99"; $bitmap8[0] = "0x99"; $bitmap9[0] = "0x99"; $bitmap10[0] = "0x99"; $bitmap11[0] = "0x99"; $bitmap12[0] = "0xc3"; $bitmap13[0] = "0xff"; $bitmap14[0] = "0xff"; $bitmap15[0] = "0xff"; $bitmap0[1] = "0xff"; $bitmap1[1] = "0xff"; $bitmap2[1] = "0xff"; $bitmap3[1] = "0xcf"; $bitmap4[1] = "0xc7"; $bitmap5[1] = "0xcf"; $bitmap6[1] = "0xcf"; $bitmap7[1] = "0xcf"; $bitmap8[1] = "0xcf"; $bitmap9[1] = "0xcf"; $bitmap10[1] = "0xcf"; $bitmap11[1] = "0xcf"; $bitmap12[1] = "0xcf"; $bitmap13[1] = "0xff"; $bitmap14[1] = "0xff"; $bitmap15[1] = "0xff"; $bitmap0[2] = "0xff"; $bitmap1[2] = "0xff"; $bitmap2[2] = "0xff"; $bitmap3[2] = "0xc3"; $bitmap4[2] = "0x99"; $bitmap5[2] = "0x9f"; $bitmap6[2] = "0x9f"; $bitmap7[2] = "0xcf"; $bitmap8[2] = "0xe7"; $bitmap9[2] = "0xf3"; $bitmap10[2] = "0xf9"; $bitmap11[2] = "0xf9"; $bitmap12[2] = "0x81"; $bitmap13[2] = "0xff"; $bitmap14[2] = "0xff"; $bitmap15[2] = "0xff"; $bitmap0[3] = "0xff"; $bitmap1[3] = "0xff"; $bitmap2[3] = "0xff"; $bitmap3[3] = "0xc3"; $bitmap4[3] = "0x99"; $bitmap5[3] = "0x9f"; $bitmap6[3] = "0x9f"; $bitmap7[3] = "0xc7"; $bitmap8[3] = "0x9f"; $bitmap9[3] = "0x9f"; $bitmap10[3] = "0x9f"; $bitmap11[3] = "0x99"; $bitmap12[3] = "0xc3"; $bitmap13[3] = "0xff"; $bitmap14[3] = "0xff"; $bitmap15[3] = "0xff"; $bitmap0[4] = "0xff"; $bitmap1[4] = "0xff"; $bitmap2[4] = "0xff"; $bitmap3[4] = "0xcf"; $bitmap4[4] = "0xcf"; $bitmap5[4] = "0xc7"; $bitmap6[4] = "0xc7"; $bitmap7[4] = "0xcb"; $bitmap8[4] = "0xcb"; $bitmap9[4] = "0xcd"; $bitmap10[4] = "0x81"; $bitmap11[4] = "0xcf"; $bitmap12[4] = "0x87"; $bitmap13[4] = "0xff"; $bitmap14[4] = "0xff"; $bitmap15[4] = "0xff"; $bitmap0[5] = "0xff"; $bitmap1[5] = "0xff"; $bitmap2[5] = "0xff"; $bitmap3[5] = "0x81"; $bitmap4[5] = "0xf9"; $bitmap5[5] = "0xf9"; $bitmap6[5] = "0xf9"; $bitmap7[5] = "0xc1"; $bitmap8[5] = "0x9f"; $bitmap9[5] = "0x9f"; $bitmap10[5] = "0x9f"; $bitmap11[5] = "0x99"; $bitmap12[5] = "0xc3"; $bitmap13[5] = "0xff"; $bitmap14[5] = "0xff"; $bitmap15[5] = "0xff"; $bitmap0[6] = "0xff"; $bitmap1[6] = "0xff"; $bitmap2[6] = "0xff"; $bitmap3[6] = "0xc7"; $bitmap4[6] = "0xf3"; $bitmap5[6] = "0xf9"; $bitmap6[6] = "0xf9"; $bitmap7[6] = "0xc1"; $bitmap8[6] = "0x99"; $bitmap9[6] = "0x99"; $bitmap10[6] = "0x99"; $bitmap11[6] = "0x99"; $bitmap12[6] = "0xc3"; $bitmap13[6] = "0xff"; $bitmap14[6] = "0xff"; $bitmap15[6] = "0xff"; $bitmap0[7] = "0xff"; $bitmap1[7] = "0xff"; $bitmap2[7] = "0xff"; $bitmap3[7] = "0x81"; $bitmap4[7] = "0x99"; $bitmap5[7] = "0x9f"; $bitmap6[7] = "0x9f"; $bitmap7[7] = "0xcf"; $bitmap8[7] = "0xcf"; $bitmap9[7] = "0xe7"; $bitmap10[7] = "0xe7"; $bitmap11[7] = "0xf3"; $bitmap12[7] = "0xf3"; $bitmap13[7] = "0xff"; $bitmap14[7] = "0xff"; $bitmap15[7] = "0xff"; $bitmap0[8] = "0xff"; $bitmap1[8] = "0xff"; $bitmap2[8] = "0xff"; $bitmap3[8] = "0xc3"; $bitmap4[8] = "0x99"; $bitmap5[8] = "0x99"; $bitmap6[8] = "0x99"; $bitmap7[8] = "0xc3"; $bitmap8[8] = "0x99"; $bitmap9[8] = "0x99"; $bitmap10[8] = "0x99"; $bitmap11[8] = "0x99"; $bitmap12[8] = "0xc3"; $bitmap13[8] = "0xff"; $bitmap14[8] = "0xff"; $bitmap15[8] = "0xff"; $bitmap0[9] = "0xff"; $bitmap1[9] = "0xff"; $bitmap2[9] = "0xff"; $bitmap3[9] = "0xc3"; $bitmap4[9] = "0x99"; $bitmap5[9] = "0x99"; $bitmap6[9] = "0x99"; $bitmap7[9] = "0x99"; $bitmap8[9] = "0x83"; $bitmap9[9] = "0x9f"; $bitmap10[9] = "0x9f"; $bitmap11[9] = "0xcf"; $bitmap12[9] = "0xe3"; $bitmap13[9] = "0xff"; $bitmap14[9] = "0xff"; $bitmap15[9] = "0xff"; sub digits { local ($num) = @_; if (length($num) < 8){ $num = '0'x(8-length($num)) .$num; } # @digits= unpack("C",$num); @digits = split('',$num); # print "count=$pcount, num=$num, digits=[",join(",",@digits),"]\n"; print "Content-Type: image/x-xbitmap\n\n"; $num = $num + 0; print "#define odo_width ",8*(1+$#digits), "\n#define odo_height 16\nstatic char odo_bits[] = {\n"; foreach $digit ( @digits ) { print $bitmap0[$digit],", "; } print "\n"; foreach $digit ( @digits ) { print $bitmap1[$digit],", "; } print "\n"; foreach $digit ( @digits ) { print $bitmap2[$digit],", "; } print "\n"; foreach $digit ( @digits ) { print $bitmap3[$digit],", "; } print "\n"; foreach $digit ( @digits ) { print $bitmap4[$digit],", "; } print "\n"; foreach $digit ( @digits ) { print $bitmap5[$digit],", "; } print "\n"; foreach $digit ( @digits ) { print $bitmap6[$digit],", "; } print "\n"; foreach $digit ( @digits ) { print $bitmap7[$digit],", "; } print "\n"; foreach $digit ( @digits ) { print $bitmap8[$digit],", "; } print "\n"; foreach $digit ( @digits ) { print $bitmap9[$digit],", "; } print "\n"; foreach $digit ( @digits ) { print $bitmap10[$digit],", "; } print "\n"; foreach $digit ( @digits ) { print $bitmap11[$digit],", "; } print "\n"; foreach $digit ( @digits ) { print $bitmap12[$digit],", "; } print "\n"; foreach $digit ( @digits ) { print $bitmap13[$digit],", "; } print "\n"; foreach $digit ( @digits ) { print $bitmap14[$digit],", "; } print "\n"; foreach $digit ( @digits ) { print $bitmap15[$digit],", "; } print "\n"; print "};\n"; } ### IMAGE SETTINGS ### $width = "24"; $height = "28"; $tp = "X"; $il = "1"; $frame_width = "8"; $frame_color = "0,0,0"; $dot = "X"; $logo = "X"; $count = "0"; ### OPTIONS ### $uselog = "1"; # 1 = YES; 0 = NO # Done ####################################################################### # Get the Date For Logging Purposes if ($uselog == 1) { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); if ($sec < 10) { $sec = "0$sec"; } if ($min < 10) { $min = "0$min"; } if ($hour < 10) { $hour = "0$hour"; } if ($mday < 10) { $mday = "0$mday"; } if ($mon < 10) { $monc = "0$mon"; } # $date = "$hour\:$min\:$sec $mon/$mday/$year"; $mon++; $date = "$mday.$mon.$year $hour\:$min\:$sec"; } # Get the Counter Number And Write New One to File &get_num; # Determine Length of Counter Number $num = $length = length($count); # Set Individual Counter Numbers Into Associative Array while ($num > 0) { $CHAR{$num} = chop($count); $num--; } # print "count=$pcount , num=$num, digits=[",join(",",@digits),"]\n"; &digits($pcount); # Determine the Height and Width of the Image $img_width = (($width * $length) + ($frame_width * 2)); $img_height = (($frame_width * 2) + $height); # Log the Counter Access if ($uselog == 1) { &log_access; } sub get_num { # open(COUNT,"$count_file") || print "Can't Open Count Data File: $!\n"; open(COUNT,"$count_file") || &log_typ("Can't Open Count Data File: $!"); $count = ; close(COUNT); if ($count =~ /\n$/) { chop($count); } $count++; $pcount = $count ; open(COUNT,">$count_file") || print "Can't Open Count Data File For Writing: $!\n"; print COUNT "$count"; close(COUNT); } sub log_access { open(LOG,">>$access_log") || die "Can't Open User Access Log: $!\n"; print LOG "[$date] $ENV{'REMOTE_HOST'} - $ENV{'HTTP_USER_AGENT'}\n"; close(LOG); } sub log_typ { local ($lstr) = @_; open(LOG,">>$access_log") || die "Can't Open User Access Log: $!\n"; print LOG "[$date] $lstr \n"; close(LOG); }