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
-
- edit filtering lists.";
-
- &link_to_help( "filter-lists", "Filter Lists" );
-
- print "
- add/delete users or change their passwords.
- First Time Users: You have to log in as admin and add a moderator user
- who will be able to moderate the newsgroup. Then log in again as that
- user. If you are a new user, you have to have your admin password assigned to
- you by the administrator.
-
-
-";
+# print "
+# Log in as \"admin\" if you want to
+#
+# edit filtering lists.";
+#
+# &link_to_help( "filter-lists", "Filter Lists" );
+#
+# print "
+# add/delete users or change their passwords.
+# First Time Users: You have to log in as admin and add a moderator user
+# who will be able to moderate the newsgroup. Then log in again as that
+# user. If you are a new user, you have to have your admin password assigned to
+# you by the administrator.
+#
+#
+#";
&end_html;
}
@@ -246,7 +247,7 @@ sub html_moderate_article {
&html_print_credentials;
print "
Approve
-Put to back of queue
+Put to back of queue
Back of queue, adding mark requesting further consideration
";
@@ -371,7 +372,6 @@ sub admin_add_newsgroup {
print "Creating files in $dir...";
- &append_to_file( "$dir/blacklist", "" );
&append_to_file( "$dir/address.txt", "$address\n" );
&append_to_file( "$dir/moderators", "ADMIN \U$password\n" );
&append_to_file( "$dir/rejection-reasons",
@@ -379,7 +379,6 @@ sub admin_add_newsgroup {
harassing::message of harassing content
charter::message poorly formatted
" );
- &append_to_file( "$dir/whitelist", "" );
print " done.\n";
@@ -614,7 +613,7 @@ No articles present in the queue
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 "
Date Reference Disposal Reason \n"
+ unless $sofar;
+ print "", (map { "".escapeHTML($_) }
+ $date,$treqnum,$act,$reason);
+ print " \n";
+ return defined($reqnum) ? 2 : 1;
+ });
+ if ($sofar) {
+ 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 " \n";
+ }
+
print "
-
List of current moderators: