6 use CGI qw/:standard *table end_* -no_xhtml/;
9 # no. of digits at end of time to replace with x, 0..4
13 last unless $ARGV[0] =~ m/^-/;
17 if (s/^-t([0-4])/-/) {
20 die "bad option $_ ?";
25 our ($ng,$staticfiles,@ARGV) = @ARGV;
32 our ($processline,$needmap);
33 our ($selectmid,$selectnum);
36 my ($taccat, $fn)= @_;
37 open F, "$taccat $fn |" or die $!;
42 $s[0]= strftime "%Y-%m-%d %H:%M:%S %Z", localtime $s[0];
43 for (my $i=0; $i<$timesquash; $i++) {
44 $s[0] =~ s/(\d\d:[\d:]*)\d/$1x/;
53 my (@logs) = qw(event.log.0 event.log);
54 @logs= reverse @logs if $taccat eq 'tac';
55 processlog($taccat, $_) foreach @logs;
58 sub processline_print () {
60 $sp[3] =~ s/\@\w{0,2}/ at .. /;
61 @sp= map { escapeHTML($_) } @sp[0..5];
62 $sp[3] =~ s/</\<br></;
63 $sp[2]=~s/\@/\@<span class='hole'><\/span>/;
65 s/\W/ sprintf "%%%02x", ord $& /ge;
68 if (length $s[1] && length $s[2]) {
69 my $url= url().'/message/'.$spu[1].'/'.$spu[2];
70 foreach my $i (qw(1 2)) {
71 $sp[$i]= a({ href=>$url }, $sp[$i]."<br>" );
75 $sp[5]= a({ href=>"$staticfiles/nr-$s[6].txt" }, $sp[5] );
78 print "<tr class='$oddeven'><td>$sp[0]</td>";
79 print "<td class='ref'>$sp[1] $sp[2]</td>";
80 print td([@sp[3..5]]),"</tr>\n";
83 sub processline_print_ifsingle () {
84 return unless $s[1] eq $selectnum
85 or $s[2] eq $selectmid;
89 our (%done_num,%done_id,%num2id,%id2num);
90 sub processline_queue_prescan () {
91 my ($num,$id,$e) = @s[1..2,5];
92 if (length $id and length $num) {
96 return unless $e =~ m/^decide reject discard|^notify reject|^post/;
97 #print STDERR "finishing $e $s[1] $s[2]\n";
98 $num= $id2num{$id} if !length $num;
99 $id= $num2id{$num} if !length $id;
100 #print STDERR "finishing $e $num $id\n";
101 $done_num{$num}++ if defined $num;
102 $done_id{$id}++ if defined $id;
104 sub processline_queue () {
105 return if $done_num{$s[1]};
106 return if $done_id{$s[2]};
114 $processline= \&processline_print;
116 if ($pi =~ m,^/message/(\d+)/(.*)$,) {
117 ($selectnum, $selectmid) = ($1,$2);
118 $title= "Single message ".escapeHTML($selectmid);
119 $processline= \&processline_print_ifsingle;
120 } elsif ($pi =~ m/^$/) {
121 $title= "Recent activity - $ng";
122 } elsif ($pi =~ m,^/queue,) {
123 $title= "Activity regarding still-queued messages";
124 $processline= \&processline_queue_prescan;
126 $processline= \&processline_queue;
130 span.hole:before { content: " "; }
131 td.ref { font-size: 0.75em; }
132 tr.o { background: #ddddff; }
136 start_html(-title=>$title, -style=>{'-code'=>$css}),
137 h1($title), start_table();
139 print Tr(td([map { strong($_) } (qw(
152 print a({ href=>url() }, "All recent activity"), '; ';
153 print a({ href=>url().'/queue' }, "Unfinished business");