#
	#     accesslog.pl
	#
	#
	# a perl script which writes an access log
	# file requirements: a log file with proper permissions set
	#
	# THIS SCRIPT REQUIRES PERMISSION SETTING ON log.txt
	
	($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); #Got the time?
	if (length($min) == 1) { $min = '0'.$min; } #pad with a zero if needed
	$date = "$mon/$mday/$year, $hour:$min:$sec";
	
	################################################
	# THESE LINES WILL NEED TO BE CHANGED, SEE INFO
	$logfile = "e:\\puffindocs\\home\\puffinpages\\handbook\\log.txt";
	# default 'goto' location
	$url = "puffin.ptialaska.net/puffinpages/handbook/results.htm";
	################################################
	
	
	$http_user_agent   = $ENV{'HTTP_USER_AGENT'};	#browser type
	$remote_address    = $ENV{'REMOTE_ADDRESS'}; 	#IP or host of browser's computer
	$remote_host    = $ENV{'REMOTE_HOST'}; 	#IP or host of browser's computer
	
	if ($ENV{'REQUEST_METHOD'} eq 'GET') 
	{      
	   @pairs = split(/&/, $ENV{'QUERY_STRING'}); # Split the name-value pairs
	}
	elsif ($ENV{'REQUEST_METHOD'} eq 'POST') 
	{
	   
	   read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Get the input
	    @pairs = split(/&/, $buffer); # Split the name-value pairs
	}
	
	foreach $pair (@pairs) {
	      ($name, $value) = split(/=/, $pair);
		if ($name == "referrer") { $document_referrer = $value;}
		if ($name == "goto") { $url = $value; }
	}
	
	$document = $ENV{'HTTP_REFERRER'};
	
	
	
	open (OUTFILE,">>$logfile") || die "could not open $logfile for appending::".$!;
	
	
		print OUTFILE "$date\t$http_user_agent\t$remote_host\t$document_referrer\n\r";
	
	close (OUTFILE);
print "Location: http://$url\n\n";
exit(0);