6 use CGI qw/:standard *table end_* -no_xhtml/;
9 # no. of digits at end of time to replace with x, 0..4
10 our %reasonshow = qw(approve 1 reject 1);
11 # no. of words to show
15 last unless $ARGV[0] =~ m/^-/;
19 if (s/^-t([0-4])/-/) {
21 } elsif (s/^-r(\w+)=(\d)$//) {
24 die "bad option $_ ?";
29 our ($ng,$staticfiles,@ARGV) = @ARGV;
36 our ($processline,$needmap);
37 our ($selectmid,$selectnum);
40 my ($taccat, $fn)= @_;
41 open F, "$taccat $fn |" or die $!;
46 $s[0]= strftime "%Y-%m-%d %H:%M:%S %Z", localtime $s[0];
47 for (my $i=0; $i<$timesquash; $i++) {
48 $s[0] =~ s/(\d\d:[\d:]*)\d/$1x/;
57 my (@logs) = qw(event.log.0 event.log);
58 @logs= reverse @logs if $taccat eq 'tac';
59 processlog($taccat, $_) foreach @logs;
62 sub processline_print () {
64 $sp[3] =~ s/\@\w{0,2}/ at .. /;
65 @sp= map { escapeHTML($_) } @sp[0..5];
66 $sp[3] =~ s/</\<br></;
67 $sp[2]=~s/\@/\@<span class='hole'><\/span>/;
69 s/\W/ sprintf "%%%02x", ord $& /ge;
72 if (length $s[1] && length $s[2]) {
73 my $url= url().'/message/'.$spu[1].'/'.$spu[2];
74 foreach my $i (qw(1 2)) {
75 $sp[$i]= a({ href=>$url }, $sp[$i]."<br>" );
79 $sp[5]= a({ href=>"$staticfiles/nr-$s[6].txt" }, $sp[5] );
82 if ($sp[5] =~ m/^\w+\b/ &&
83 defined (my $reasonshow= $reasonshow{$&})) {
84 my @reas= split /\s+/, $sp[5];
86 $#reas = $reasonshow if $#reas > $reasonshow;
87 $sp[5] = join ' ', @reas;
90 print "<tr class='$oddeven'><td>$sp[0]</td>";
91 print "<td class='ref'>$sp[1] $sp[2]</td>";
92 print td([@sp[3..5]]),"</tr>\n";
95 sub processline_print_ifsingle () {
96 return unless $s[1] eq $selectnum
97 or $s[2] eq $selectmid;
101 our (%done_num,%done_id,%num2id,%id2num);
102 sub processline_queue_prescan () {
103 my ($num,$id,$e) = @s[1..2,5];
104 if (length $id and length $num) {
108 return unless $e =~ m/^decide reject discard|^notify reject|^post/;
109 #print STDERR "finishing $e $s[1] $s[2]\n";
110 $num= $id2num{$id} if !length $num;
111 $id= $num2id{$num} if !length $id;
112 #print STDERR "finishing $e $num $id\n";
113 $done_num{$num}++ if defined $num;
114 $done_id{$id}++ if defined $id;
116 sub processline_queue () {
117 return if $done_num{$s[1]};
118 return if $done_id{$s[2]};
126 $processline= \&processline_print;
128 if ($pi =~ m,^/message/(\d+)/(.*)$,) {
129 ($selectnum, $selectmid) = ($1,$2);
130 $title= "Single message ".escapeHTML($selectmid);
131 $processline= \&processline_print_ifsingle;
132 } elsif ($pi =~ m/^$/) {
133 $title= "Recent activity - $ng";
134 } elsif ($pi =~ m,^/queue,) {
135 $title= "Activity regarding still-queued messages";
136 $processline= \&processline_queue_prescan;
138 $processline= \&processline_queue;
142 span.hole:before { content: " "; }
143 td.ref { font-size: 0.75em; }
144 tr.o { background: #ddddff; }
148 start_html(-title=>$title, -style=>{'-code'=>$css}),
149 h1($title), start_table();
151 print Tr(td([map { strong($_) } (qw(
164 print a({ href=>url() }, "All recent activity"), '; ';
165 print a({ href=>url().'/queue' }, "Unfinished business");