chiark / gitweb /
Correct regexp
[modbot-mtm.git] / webstump / scripts / html_output.pl
index aca05099ff64af4af4a6b279818461a30247086f..e460fe36363ba7c35385117cf74ae9c8033c415f 100644 (file)
@@ -247,7 +247,7 @@ sub html_moderate_article {
   &html_print_credentials;
   print "<SELECT NAME=\"decision_$file\">
 <OPTION VALUE=\"approve\">Approve</OPTION>
-<OPTION VALUE=\"leave\">Put to back of queue</OPTION>
+<OPTION VALUE=\"leave\" SELECTED>Put to back of queue</OPTION>
 <OPTION VALUE=\"consider\">Back of queue, adding mark requesting further consideration</OPTION>
 ";
 
@@ -640,22 +640,24 @@ sub scanlogs ($$$) {
     my $num= sub {
         local ($_) = @_;
         return $forwards * (
-            m/^errs$/ ? -1 :
-            m/^errs\.(\d+)(?:\.gz$)$/ ? $1 :
-            undef
+            m/^errs$/ ? 1 :
+            m/^errs\.(\d+)(?:\.gz)?$/ ? ($1+2) :
+            0
                            );
     };
     foreach my $leaf (
                       sort { $num->($a) <=> $num->($b) }
-                      grep { defined $num->($_) }
+                     grep { $num->($_) }
                       readdir LOGSDIR
                       ) {
         my $file= "$dir/$leaf";
-        if ($file =~ m/\.gz$/) {
-            open LOGFILE, "zcat $file |" or die "zcat $file $!";
+        if ($file =~ m/\/errs.*\.gz$/) {
+            open LOGFILE, "zcat $file | tac |" or die "zcat $file | tac $!";
+        } elsif ($file =~ /errs/) {
+            open LOGFILE, "tac $file |" or die "tac $file $!";
         } else {
-            open LOGFILE, "< $file" or die "$file $!";
-        }
+           die "Unexpected filename in scanlogs: $file";
+       }
         while (<LOGFILE>) {
             my $tgot= $callback->();
             next unless $tgot;
@@ -676,7 +678,7 @@ sub html_search_logs {
   if ($request{'download_logs'}) {
       print "<h2>Complete log download</h2>\n";
       $min= 2;
-  } elsif ($request{'messagenum'} =~ m/^(\d+)$/) {
+  } elsif ($request{'messagenum'} =~ m/^\s*(\d+)\s*$/) {
       $reqnum= $1;
       $forwards= -1;
       $min= 1;
@@ -703,14 +705,17 @@ and are often quoted in message headers in [square brackets].<p>
       my @vals = split / \| /, $';
       return 0 unless @vals >= 5;
       my $subj= pop @vals;
-      my ($group,$dir,$act,$reason) = @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 "<table rules=all><tr><th>Reference<th>Disposal<th>Reason</tr>\n"
+      print "<table rules=all><tr><th>Date<th>Reference<th>Disposal<th>Reason</tr>\n"
           unless $sofar;
-      print "<tr>", (map { "<td>".escapeHTML($_) } $treqnum,$act,$reason);
+      print "<tr>", (map { "<td>".escapeHTML($_) }
+                     $date,$treqnum,$act,$reason);
       print "</tr>\n";
       return defined($reqnum) ? 2 : 1;
   });
@@ -718,7 +723,8 @@ and are often quoted in message headers in [square brackets].<p>
       print "</table>" if $sofar;
       print "\n";
   } else {
-      print "Reference not found.";
+      print "Reference not found.".
+          "  (Perhaps message has expired, or is still in the queue?)";
   }
   &end_html;
 }