#!/usr/bin/perl #This program is a combined logbook and counter. #Created with WordPad, by Fredrik Siesing, WprFeb99 #Declare variables #$rad1 #$antal #$1 #$lock #$unlock #$loggbok #$datum open (RAKNARE, "raknare.txt"); #Opens raknare.txt for reading. $rad1 = ; #Reads line 1 and saves it in $rad1. close (RAKNARE); #Closes raknare.txt. $rad1=~/Antalet=(.*)st/; #Finds the numbers between "Antalet=" and "st" #and saves it to $1. $antal = $1; #The old number is moved to $antal. $antal ++; #Adding 1 to the number. print "Content-type: text/html\n\n"; #HTTP-head is written. print ""; print "Du är besökare nr. $antal på denna sida!"; #The number is written to the webpage. print ""; open (RAKNARE, ">raknare.txt"); #Opens raknare.txt for overwriting. print RAKNARE "Antalet=",$antal,"st\n"; #The new number is written out. close (RAKNARE); #Closes raknare.txt. $lock = 2; $unlock = 8; $loggbok = "logg.txt"; #Saves logg.txt to the variable $loggbok. $datum = `date`; #Saves the date to the variable $datum; chomp ($datum); #The Enterstrike is being chopped off. print "Content-type: text/plain\n\n"; #HTTP-head is written. if (open (LOGG, ">>$loggbok")) { #Opens loggbok.txt for writing. flock (LOGG,$lock); #Locks the file loggbok.txt. } print LOGG "Tid & Datum: $datum\n"; #Time and date are written out. print LOGG "AnvändarNamn: $ENV{´REMOTE_IDENT´}\n"; #The environmental variables are written out. print LOGG "Värd: $ENV{´REMOTE_HOST´}\n"; print LOGG "IpAdress: $ENV{´REMOTE_ADDR´}\n"; print LOGG "WebbLäsare: $ENV{´HTTP_USER_AGENT´}\n"; print LOGG "Besökt Sida: $ENV{´DOCUMENT_URL´}\n"; print LOGG "Kom Ifrån: $ENV{´HTTP_REFERER´}\n\n"; #2 enterstrikes to the next post. flock (LOGG,$unlock); #Unlocks the file loggbok.txt. close (LOGG); #Closes loggbok.txt. exit; #Ends the program.