#
use POSIX;
+use CGI qw/escapeHTML/;
sub begin_html {
my $title = pop( @_ );
print "<FORM METHOD=$request_method action=$base_address>";
&html_print_credentials;
print "<INPUT NAME=action VALUE=moderator_admin TYPE=hidden>
- <INPUT TYPE=submit VALUE=\"Manage pass/grey/block-lists\">
+ <INPUT TYPE=submit VALUE=\"Management\">
</FORM>";
&end_html;
<INPUT NAME=password VALUE=\"$password\" TYPE=hidden>\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 (<LOGFILE>) {
+ 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 "<h2>Complete log download</h2>\n";
+ $min= 2;
+ } elsif ($request{'messagenum'} =~ m/^(\d+)$/) {
+ $reqnum= $1;
+ $forwards= -1;
+ $min= 1;
+ print "<h2>Log entry for single message $reqnum</h2>\n";
+ } else {
+ print "<h2>Log lookup - bad reference</h2>
+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].<p>
+ ";
+ &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) = @vals;
+ 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 "<table rules=all><tr><th>Reference<th>Disposal<th>Reason</tr>\n"
+ unless $sofar;
+ print "<tr>", (map { "<td>".escapeHTML($_) } $treqnum,$act,$reason);
+ print "</tr>\n";
+ return defined($reqnum) ? 2 : 1;
+ });
+ if ($sofar) {
+ print "</table>" if $sofar;
+ print "\n";
+ } else {
+ print "Reference not found.";
+ }
+ &end_html;
+}
+
# newsgroup admin page
sub html_newsgroup_management {
&begin_html( "Administer $request{'newsgroup'}" );
&link_to_help( "filter-lists", "filtering lists" );
+ print "</FORM><HR>";
+
+ if ($mod_log_access) {
+ print "<form>
+ Use this form to search logs of past moderation decisions:
+ <br>
+ <form method=$request_method action=$base_address>
+ <input name=action value=search_logs type=hidden>";
+
+ &html_print_credentials;
+
+ print "
+ Reference number: <input name=messagenum size=30>
+ <input type=submit value=\"Lookup\">";
+
+ print "
+ <input type=submit value=\"Download all logs\" name=\"download_logs\">"
+ if $mod_log_access >= 2;
+
+ print "</form><hr>\n";
+ }
+
print "
- </FORM><HR>
List of current moderators:<P>