#!perl # 1. errorlog.pl parses and displays apache errorlogs # 2. just change $error_log and $apache to your paths # 3. cookies remember the list size and filter status use strict; use CGI qw(:standard); use CGI::Cookie; use HTML::Entities; my$error_log = 'c:\path\to\error.log'; # CHANGE my$apache = 'c:\path\to\Apache\Apache.exe: '; # CHANGE but, leave space at end. my$show = 10; # default number of errors to show my@EL = stat $error_log; my%cookies = fetch CGI::Cookie; my%i = map{$_ => param($_)} param; my$url = url(); my$time = localtime(); $time =~s| .{4}$||o; open (ELOG,"<".$error_log) or die "$!"; my@elog=; close (ELOG) or die "$!"; my($cc,$c1,$c2); if($cookies{'show'}){ unless($i{'n'}=~/\d+/){ $show = $cookies{'show'}->value; } } if($i{'n'}=~/\d+/){ $show=$i{'n'}; $c1 = new CGI::Cookie(-name=>'show',-value=>"$show",-expires=>'+1y'); } if(($cookies{'clean'}=~/yes/) or ($i{'do'}=~/clean/)){ if($i{'do'}=~/clean/){ $c2 = new CGI::Cookie(-name=>'clean',-value=>'yes',-expires=>'+1y'); } $cc=' checked'; } if(($i{'go'}=~/show/) && ($i{'do'}!~/clean/)){ $c2 = new CGI::Cookie(-name=>'clean',-value=>'no',-expires=>'+1y'); $cc=(); } print header(-cookie=>[$c1,$c2]); print< $show Recent $ENV{'SERVER_NAME'} Server Errors

$show Recent $ENV{'SERVER_NAME'} Server Errors
$time

clean  

HTML @elog=reverse(@elog); my$c=0; foreach my $ln(@elog){ unless($c==$show){ &encode_entities($ln); $ln=~s|\Q$apache||oi; if($cc=~/checked/){ $ln=~s/\s\[(?:notice|error|warn)\]\s\[client.*\]//o; $ln=~s/\s2\d{3}]/\]
/o; $ln=~s/\[//o; $ln=~s|\]|\n|o; } print $ln.'
'; $c++ } } print< $error_log = $EL[7] bytes HTML exit