3 our ($ng,$staticfiles,@ARGV) = @ARGV;
9 use CGI qw/:standard *table end_* -no_xhtml/;
15 our ($processline,$needmap);
16 our ($selectmid,$selectnum);
19 my ($taccat, $fn)= @_;
20 open F, "$taccat $fn |" or die $!;
25 $s[0]= strftime "%Y-%m-%d %H:%M %Z", localtime $s[0];
26 $s[0] =~ s/(\d+\:\d)\d/${1}x/;
33 my (@logs) = qw(event.log.0 event.log);
34 @logs= reverse @logs if $taccat eq 'tac';
35 processlog($taccat, $_) foreach @logs;
38 sub processline_print () {
40 $sp[3] =~ s/\@\w{0,2}/ at .. /;
41 @sp= map { escapeHTML($_) } @sp[0..5];
42 $sp[3] =~ s/</\<br></;
43 $sp[2]=~s/\@/\@<span class='hole'><\/span>/;
45 s/\W/ sprintf "%%%02x", ord $& /ge;
48 if (length $s[1] && length $s[2]) {
49 my $url= url().'/message/'.$spu[1].'/'.$spu[2];
50 foreach my $i (qw(1 2)) {
51 $sp[$i]= a({ href=>$url }, $sp[$i]."<br>" );
55 $sp[5]= a({ href=>"$staticfiles/nr-$s[6].txt" }, $sp[5] );
58 print "<tr class='$oddeven'><td>$sp[0]</td>";
59 print "<td class='ref'>$sp[1] $sp[2]</td>";
60 print td([@sp[3..5]]),"</tr>\n";
63 sub processline_print_ifsingle () {
64 return unless $s[1] eq $selectnum
65 or $s[2] eq $selectmid;
69 our (%done_num,%done_id,%num2id,%id2num);
70 sub processline_queue_prescan () {
71 my ($num,$id,$e) = @s[1..2,5];
72 if (length $id and length $num) {
76 return unless $e =~ m/^decide reject discard|^notify reject|^post/;
77 #print STDERR "finishing $e $s[1] $s[2]\n";
78 $num= $id2num{$id} if !length $num;
79 $id= $num2id{$num} if !length $id;
80 #print STDERR "finishing $e $num $id\n";
81 $done_num{$num}++ if defined $num;
82 $done_id{$id}++ if defined $id;
84 sub processline_queue () {
85 return if $done_num{$s[1]};
86 return if $done_id{$s[2]};
94 $processline= \&processline_print;
96 if ($pi =~ m,^/message/(\d+)/(.*)$,) {
97 ($selectnum, $selectmid) = ($1,$2);
98 $title= "Single message ".escapeHTML($selectmid);
99 $processline= \&processline_print_ifsingle;
100 } elsif ($pi =~ m/^$/) {
101 $title= "Recent activity - $ng";
102 } elsif ($pi =~ m,^/queue,) {
103 $title= "Activity regarding still-queued messages";
104 $processline= \&processline_queue_prescan;
106 $processline= \&processline_queue;
110 span.hole:before { content: " "; }
111 td.ref { font-size: 0.75em; }
112 tr.o { background: #ddddff; }
116 start_html(-title=>$title, -style=>{'-code'=>$css}),
117 h1($title), start_table();
119 print Tr(td([map { strong($_) } (qw(
132 print a({ href=>url() }, "All recent activity"), '; ';
133 print a({ href=>url().'/queue' }, "Unfinished business");