X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~webstump/git?p=modbot-mtm.git;a=blobdiff_plain;f=webstump%2Fscripts%2Fhtml_output.pl;h=5503b4ae6104a3566e993c03f5ad1f69b87c9281;hp=e99c8d1d109dd1ecc4b060d18831036f115de81c;hb=1e6dc8d0b0280d4efd3d9c5d4032fec159b89d52;hpb=56d8a80761d68c123d55778d73b66268dabd3e34 diff --git a/webstump/scripts/html_output.pl b/webstump/scripts/html_output.pl index e99c8d1..5503b4a 100644 --- a/webstump/scripts/html_output.pl +++ b/webstump/scripts/html_output.pl @@ -7,6 +7,7 @@ # use POSIX; +use CGI qw/escapeHTML/; sub begin_html { my $title = pop( @_ ); @@ -149,22 +150,22 @@ this page.
"; for example, \"xyzzy\" and \"XyZZY\" are equally valid.

"; - print " - Log in as \"admin\" if you want to -

- -"; +# print " +# Log in as \"admin\" if you want to +# +# +#"; &end_html; } @@ -246,7 +247,7 @@ sub html_moderate_article { &html_print_credentials; print " - + "; &end_html; @@ -632,6 +631,102 @@ sub html_print_credentials { \n"; } +# logs + +sub scanlogs ($$$) { + my ($forwards, $gotr, $callback) = @_; + my $dir= "$webstump_home/.."; + opendir LOGSDIR, "$dir" or die "$dir $!"; + my $num= sub { + local ($_) = @_; + return $forwards * ( + m/^errs$/ ? -1 : + m/^errs\.(\d+)(?:\.gz$)$/ ? $1 : + undef + ); + }; + foreach my $leaf ( + sort { $num->($a) <=> $num->($b) } + grep { defined $num->($_) } + readdir LOGSDIR + ) { + my $file= "$dir/$leaf"; + if ($file =~ m/\.gz$/) { + open LOGFILE, "zcat $file |" or die "zcat $file $!"; + } else { + open LOGFILE, "< $file" or die "$file $!"; + } + while () { + my $tgot= $callback->(); + next unless $tgot; + $$gotr= $tgot if $tgot > $$gotr; + last if $tgot > 1; + } + $!=0; $?=0; close LOGFILE or die "$file $? $!"; + last if $$gotr > 1; + } + closedir LOGSDIR or die "$dir $!"; +} + +sub html_search_logs { + &begin_html("Search logs for $request{'newsgroup'}"); + my $reqnum; + my $forwards=1; + my $min= 9; + if ($request{'download_logs'}) { + print "

Complete log download

\n"; + $min= 2; + } elsif ($request{'messagenum'} =~ m/^\s*(\d+)\s*$/) { + $reqnum= $1; + $forwards= -1; + $min= 1; + print "

Log entry for single message $reqnum

\n"; + } else { + print "

Log lookup - bad reference

+Please supply the numerical reference as found in the \"recent activity\" +log or message headers. Reference numbers consist entirely of digits, +and are often quoted in message headers in [square brackets].

+ "; + &end_html; + return; + } + if ($mod_log_access < $min) { + print "Not permitted [$mod_log_access<$min]. Consult administrator.\n"; + &end_html; + return; + } + + my $sofar= 0; + &scanlogs($forwards, \$sofar, sub { + return 0 unless chomp; + return 0 unless m/^DECISION: /; + my @vals = split / \| /, $'; + return 0 unless @vals >= 5; + my $subj= pop @vals; + my ($group,$dir,$act,$reason,$timet) = @vals; + my $date= $timet ? (strftime "%Y-%m-%d %H:%M:%S GMT", gmtime $timet) + : "(unknown)"; + return 0 unless $group eq $request{'newsgroup'}; + return 0 unless $subj =~ m,/(\d+)$,; + my $treqnum= $1; + return 0 if defined($reqnum) and $treqnum ne $reqnum; + print "\n" + unless $sofar; + print "", (map { "\n"; + return defined($reqnum) ? 2 : 1; + }); + if ($sofar) { + print "
DateReferenceDisposalReason
".escapeHTML($_) } + $date,$treqnum,$act,$reason); + print "
" if $sofar; + print "\n"; + } else { + print "Reference not found.". + " (Perhaps message has expired, or is still in the queue?)"; + } + &end_html; +} + # newsgroup admin page sub html_newsgroup_management { &begin_html( "Administer $request{'newsgroup'}" ); @@ -683,8 +778,29 @@ sub html_newsgroup_management { &link_to_help( "filter-lists", "filtering lists" ); + print "


"; + + if ($mod_log_access) { + print "
+ Use this form to search logs of past moderation decisions: +
+ + "; + + &html_print_credentials; + + print " + Reference number: + "; + + print " + " + if $mod_log_access >= 2; + + print "

\n"; + } + print " -
List of current moderators: