#!/usr/local/bin/perl #use strict; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser carpout); use Time::Local; # Grab information returned by web page $hour = param ("hour"); $minute = param ("minute"); # Allow perl to write to browser window print "Content-type: text/html\n\n"; # Current time in seconds $now = time; # Convert submitted time to seconds $compare_time = ($hour * 3600) + ($minute * 60); # Times extracted by logs must be >= to $target $target = $now - $compare_time; open LOGFILE, "datafile.html" || die "Can't open file"; @log_data =; # Grab useful information from each line of the web log foreach $log_line(@log_data) { # Grab date/time and referer ($date_string, $referrer) = ($log_line =~ /\([^\]+)\] "^"+"^"+"(^"+)"/); # Replace / and : with spaces $date_string =~ s!/! !g; $date_string =~ s!:! !g; # Dump junk at end of line $date_string =~ s! -0-9+!!; # Split date/time into useful information ($day, $month, $year, $hhour, $min, $sec) = split(' ', $date_string); # Convert month from text to number if ($month == 'Jan') {$month = 0} elsif ($month == 'Feb') {$month = 1} elsif ($month == 'Mar') {$month = 2} elsif ($month == 'Apr') {$month = 3} elsif ($month == 'May') {$month = 4} elsif ($month == 'Jun') {$month = 5} elsif ($month == 'Jul') {$month = 6} elsif ($month == 'Aug') {$month = 7} elsif ($month == 'Sep') {$month = 8} elsif ($month == 'Oct') {$month = 9} elsif ($month == 'Nov') {$month = 10} else {$month = 11} # Calculate time on the log line in seconds $log_time = timelocal($sec,$min,$hhour,$day,$month,$year); if ($log_time >= $target) { push @refers, $referrer; } } Some data:
216.45.43.42 - - 12/Dec/2002:18:39:15 -0500 "GET /news/opinions/varvel.gif HTTP/1.1" 302 313 "http://www.freerepublic.com/forum/a3a95ca3c24a0.htm" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)"
12.222.75.65 - - 12/Dec/2002:18:39:15 -0500 "GET /images/header_aod2_15.gif HTTP/1.1" 200 4162 "http://www.indystar.com/print/articles/1/007735-7671-036.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90; MSOCD; Q312461; YComp 5.0.0.0; .NET CLR 1.0.3705)"
12.222.75.65 - - 12/Dec/2002:18:39:15 -0500 "GET /images/storysearch2.gif HTTP/1.1" 200 142 "http://www.indystar.com/print/articles/1/007735-7671-036.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90; MSOCD; Q312461; YComp 5.0.0.0; .NET CLR 1.0.3705)"
12.222.75.65 - - 12/Dec/2002:18:39:15 -0500 "GET /users/ads/misc/remax_searchad3.gif HTTP/1.1" 200 2335 "http://www.indystar.com/print/articles/1/007735-7671-036.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90; MSOCD; Q312461; YComp 5.0.0.0; .NET CLR 1.0.3705)"
12.222.75.65 - - 12/Dec/2002:18:39:16 -0500 "GET /images/sports_03_aod.gif HTTP/1.1" 200 3195 "http://www.indystar.com/print/articles/1/007735-7671-036.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90; MSOCD; Q312461; YComp 5.0.0.0; .NET CLR 1.0.3705)"
12.222.75.65 - - 12/Dec/2002:18:39:16 -0500 "GET /images/email.gif HTTP/1.1" 200 138 "http://www.indystar.com/print/articles/1/007735-7671-036.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90; MSOCD; Q312461; YComp 5.0.0.0; .NET CLR 1.0.3705)"
12.222.75.65 - - 12/Dec/2002:18:39:16 -0500 "GET /images/print.gif HTTP/1.1" 200 139 "http://www.indystar.com/print/articles/1/007735-7671-036.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90; MSOCD; Q312461; YComp 5.0.0.0; .NET CLR 1.0.3705)"
12.222.75.65 - - 12/Dec/2002:18:39:16 -0500 "GET /images/sidelinksend2.gif HTTP/1.1" 200 1009 "http://www.indystar.com/print/articles/1/007735-7671-036.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90; MSOCD; Q312461; YComp 5.0.0.0; .NET CLR 1.0.3705)"
12.222.75.65 - - 12/Dec/2002:18:39:16 -0500 "GET /images/pics2/image-007735-7410.jpg HTTP/1.1" 200 18319 "http://www.indystar.com/print/articles/1/007735-7671-036.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90; MSOCD; Q312461; YComp 5.0.0.0; .NET CLR 1.0.3705)"
12.222.75.65 - - 12/Dec/2002:18:39:16 -0500 "GET /images/advertisement_250strip.gif HTTP/1.1" 200 238 "http://www.indystar.com/print/articles/1/007735-7671-036.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90; MSOCD; Q312461; YComp 5.0.0.0; .NET CLR 1.0.3705)"
12.222.75.65 - - 12/Dec/2002:18:39:17 -0500 "GET /users/ads/story/macselect/macselect_250_Oct.gif HTTP/1.1" 200 10436 "http://www.indystar.com/print/articles/1/007735-7671-036.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90; MSOCD; Q312461; YComp 5.0.0.0; .NET CLR 1.0.3705)"