#!/usr/bin/perl -w use strict; use CGI qw(:standard); my $domain; &get_domain; &do_log if defined ($domain = param('Domain')); sub get_domain { my $title; if ($domain) {$title = "access log for domain $domain"} else {$title = 'access log: select domain'} print header, start_html(-title=>'access log: select domain'), startform( -method=>'POST', -action=>'access.pl', ), hr, 'Enter Domain Name: ', textfield('Domain'), br,br, submit, endform, hr, end_html; } sub do_log { my $file = '/home/htdocs/logs/access_log'; # put your log file +name and path here my @ignores = ( # suppress log entries that match any of these: '^62\.253\.128\.5', 'Scooter_trk', 'css HTTP', 'bmp HTTP', 'gif HTTP', 'htm HTTP', 'jpg HTTP', 'robots\.txt', 'http:\/\/blogdex\.media\.mit\.edu\/\/', ); my $ignores = join ("|",@ignores); my @log; open LG, $file or die "can't open $file $!"; while (<LG>) { next if /$ignores/; unshift @log, $_ if /$domain/; } my $count = 0; my $lastlog; while ($count < @log) { $log[$count] =~ /^(.*?) - - \[(.*?)].*?"GET \/(.*?) HTTP.*?".* +?"(.*?)".*?".*?" (.*)$/; if ($lastlog ne $1) { print hr, substr ($2, 0, 17)," ",$1, br; } $lastlog = $1; print " ",b("$5/$3"); print " (from $4)" unless $4 =~ /$5/; print br; $count ++; } }
In reply to Access Log Reader by George_Sherston
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |