#!/usr/bin/perl use strict; use CGI; $| = 1; my($key) = q[YOUR PASSWORD HERE]; # EDIT THIS LINE! my($cgi) = CGI->new(); my($limit) = $cgi->param('limit') || 300; my(@log) = (); my($logfile) = '/path/to/your/error.log'; # EDIT THIS LINE! my($pswd) = $cgi->param('pw') || ''; my($pattern) = $cgi->param('pattern'); if ($pswd ne $key) { &authenticate(); } elsif ($pswd eq $key) { &admit(); } exit; sub authenticate { print( $cgi->header(), qq[
] ); } sub admit { print( $cgi->header(), qq[
] ); 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) ? $pattern : 0; my $criterion = ($limit) ? ($saved - $limit) : 0; if ( (length($line) > 2) and ($i > $criterion ) ) { if ($re) { if ($line =~ /$re/) { print qq|$i\.) $line
| and --$i; } } else { print qq|$i\.) $line
| and --$i; } } } print( qq[
] ); }