#!/usr/bin/perl ############################################################### # Copyleft: Volkard Henkel # URL: http://www.normannia.de/members/volkard/vhcount # Please feel free to distribute and use this program. # Send me email to let me know where it is being used! # Comments, feedback and suggestions to volkard@normannia.de ############################################################### # This is a simple counter, not requiring SSI. Therefore # it sends e-mails to you, informing about the counter # states of the pages. # # The great graphic is borrowed from img_counter.pl # by Kevin Meltzer . # http://www.perlguy.com/perl/img_cnt.htm # His counter has also graphics options. Have a look at it. # # Syntax: # # For example there {steht?} in the file index.html: # # Very nice is the usage together with Java Script # like in the following example: # # # Installation: # - Save the program in the directory cgi-bin. # - After saving the program in the directory cgi-bin # you must call # chmod 755 vhcount.pl # You can't do this with the FTP-client, that is delivered # with Windows95. Use another FTP-client or telnet. # - change the following three variables ############################################################### # Dies ist ein einfacher Counter, der ohne SSI auskommt. Dafuer # schickt er Ihnen aber automatisch e-Mails, in der Sie ueber # den Zaehlerstand der Seiten informiert werden. # # Die tolle Grafik ist geliehen bei img_counter.pl # von Kevin Meltzer . # http://www.perlguy.com/perl/img_cnt.htm # Sein Counter hat soger Grafik-Optionen. Schauen sie ihn mal an. # # Syntax: # # Zum Beispiel steht in der Datei index.html: # # Sehr nett ist die Verwndung zusammen mit Java Skript wie # in folgendem Beispiel: # # # Installation: # - Speichern Sie das Programm im Verzeichnis cgi-bin. # - Nach dem Speichern des Programms im Verzeichnis cgi-bin # muessen Sie noch # chmod 755 vhcount.pl # aufrufen. Das koennen Sie nicht mit dem FTP-Programm, das bei # Windows95 mitgeliefert wird. Verwenden Sie ein anderes # FTP-Programm oder telnet. # - Aendern Sie die folgenden drei Variablen $email = "name\@domain.com"; $subject = "vhcount"; $frequency = 100; ############################################################### # From here you need not to alter the code. # Ab hier brauchen Sie nichts mehr zu aendern. @digits = ("3c 66 66 66 66 66 66 66 66 3c", # 0 "30 38 30 30 30 30 30 30 30 30", # 1 "3c 66 60 60 30 18 0c 06 06 7e", # 2 "3c 66 60 60 38 60 60 60 66 3c", # 3 "30 30 38 38 34 34 32 7e 30 78", # 4 "7e 06 06 06 3e 60 60 60 66 3c", # 5 "38 0c 06 06 3e 66 66 66 66 3c", # 6 "7e 66 60 60 30 30 18 18 0c 0c", # 7 "3c 66 66 66 3c 66 66 66 66 3c", # 8 "3c 66 66 66 66 7c 60 60 30 1c"); # 9 ############################################################### # increment counter # Zaehler erhoehen $pagepath = $ENV{QUERY_STRING}; open(FILE, ">>vhcount.dat"); close(FILE); open(FILE, "vhcount.dat"); @indata = ; close(FILE); $totalReads = 0; open(FILE, ">vhcount.dat"); foreach $temp (@indata) { chop($temp); ($uri, $count) = split(/\|/, $temp); if ($uri eq $pagepath) { $count++; $totalReads=$count; } print FILE "$uri|$count\n"; } if ($totalReads eq 0) { $totalReads=1; print FILE "$pagepath|1\n"; } close(FILE); ############################################################### # send e-mail # e-Mail versenden if($totalReads % $frequency == 0) { open(MAIL,"|mail -s $subject $email"); print MAIL "$pagepath\n"; print MAIL "$totalReads\n"; close(MAIL); } ############################################################### # convert counter to bytes # Zaehler in bytes umwandeln $count = $totalReads; @bytes = (); $len = length($count); $formattedCount = sprintf("%0${len}d",$count); for ($y=0; $y < 10; $y++) { for ($x=0; $x < $len; $x++) { $digit = substr($formattedCount,$x,1); $byte = substr($digits[$digit],$y*3,2); push(@bytes,$byte); } } ############################################################### # grafics output # Grafik ausgeben # Thanks to Tagen Ata Software Free Fund. for the following two lines! print "Pragma: no-cache\n"; print "Expires: Thu, 01 Dec 1994 16:00:00 GMT\n"; print ("Content-type: image/x-xbitmap\n\n"); printf ("#define count_width %d\n#define count_height 10\n", $len*8); printf STDOUT "static char count_bits[] = {\n"; for($i = 0; $i < ($#bytes + 1); $i++) { print("0x$bytes[$i]"); if ($i != $#bytes) { print(","); if (($i+1) % 7 == 0) { print("\n"); } } } print("};\n");