#!/usr/bin/perl use strict; use CGI; # Your password to access the # program over the web goes # inside these brackets -----+ # | my($accesskey) = q[foo];# <--+ $| = 1; my($cgi) = CGI->new(); my($limit) = $cgi->param('limit') || 300; my(@log) = (); my($logfile) = '/home/www/atrixnet/cgi-bin/logs/access.log'; my($pswd) = $cgi->param('pw') || ''; my($pattern) = $cgi->param('pattern'); my($filter) = $cgi->param('filter'); if ($pswd ne $accesskey) { &authenticate(); } elsif ($pswd eq $accesskey) { &admit(); } exit; sub authenticate { print( $cgi->header(), qq[ Access Log

Access Log for $ENV{'SERVER_NAME'}


Password

match pattern

filter pattern

Maximum Lines displayed

 

] ); } sub admit { print( $cgi->header(), qq[ Access Log

Access Log for $ENV{'SERVER_NAME'}



skip to bottom


] );

   open(LOG,"<$logfile") or print "can't open $logfile for reading: $!";
   @log = ;
   close LOG;

   my $i = ($#log + 1);
   my $saved = $i;

   LOGSCAN: foreach my $line (reverse @log) {
      my $re        = (length($pattern) > 0) ? qr/$pattern/o : 0;
      my($negre)    = (length($filter) > 0) ? qr/$filter/o : 0;
      my $criterion = ($limit) ? ($saved - $limit) : 0;
      my($match)    = 0;
      if (
          (length($line) > 2) and
          ($i > $criterion )
          ) {

         if ($re or $negre) {

            if ($re) {

               if ($line !~ /$re/) {

                  next;
               }
               else {

                  $match++;
               }
            }

            if ($negre) {

               if ($line =~ /$negre/) {

                  next;
               }
               else {

                  $match++;
               }
            }

            if ($match) {

               print qq|$i\.) $line

| and --$i; } else { next; } } else { print qq|$i\.) $line

| and --$i; } } } print( qq[
top

 

] ); } __END__