2 ################################################################################
4 # File: $RCSfile: detail.cgi,v $
5 # Revision: $Revision: 1.1 $
6 # Description: Displays list of email addresses based on report type.
7 # Author: Andrew@DeFaria.com
8 # Created: Fri Nov 29 14:17:21 2002
9 # Modified: $Date: 2013/06/12 14:05:47 $
12 # (c) Copyright 2000-2006, Andrew@DeFaria.com, all rights reserved.
14 ################################################################################
18 use MIME::Words qw(:all);
20 use CGI qw(:standard *table start_td end_td start_Tr end_Tr start_div end_div);
21 use CGI::Carp 'fatalsToBrowser';
25 local $0 = $FindBin::Script;
27 use lib "$FindBin::Bin/../lib";
34 my $type = param 'type';
35 my $next = param 'next';
36 my $lines = param 'lines';
37 my $date = param 'date';
41 my ($userid, $current, $last, $prev, $total);
43 my $table_name = 'detail';
48 'The following blacklisted users attempted to email you'
52 'Delivered email from the following users'
56 'Discarded messages from the following users'
64 'Automatically detected mail loops from the following users'
68 'The following users have recently registered'
72 'Sent Register reply to the following users'
79 my $prev_button = $prev >= 0 ?
80 a ({-href => "detail.cgi?type=$type;date=$date;next=$prev",
82 }, '<img src=/maps/images/previous.gif border=0 alt=Previous align=middle>') : '';
83 my $next_button = ($next + $lines) < $total ?
84 a {-href => "detail.cgi?type=$type;date=$date;next=" . ($next + $lines),
86 }, '<img src=/maps/images/next.gif border=0 alt=Next align=middle>' : '';
88 my $buttons = $prev_button;
90 if ($type eq 'whitelist') {
92 submit ({-name => 'action',
93 -value => 'Blacklist',
94 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . ' ' .
95 submit ({-name => 'action',
97 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . ' ' .
98 submit ({-name => 'action',
100 -onClick => 'return ClearAll (document.detail);'});
101 } elsif ($type eq 'blacklist') {
102 $buttons = $buttons .
103 submit ({-name => 'action',
104 -value => 'Whitelist',
105 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . ' ' .
106 submit ({-name => 'action',
107 -value => 'Nulllist',
108 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . ' ' .
109 submit ({-name => 'action',
111 -onClick => 'return ClearAll (document.detail);'});
112 } elsif ($type eq 'nulllist') {
113 $buttons = $buttons .
114 submit ({-name => 'action',
115 -value => 'Whitelist',
116 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . ' ' .
117 submit ({-name => 'action',
118 -value => 'Blacklist',
119 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . ' ' .
120 submit ({-name => 'action',
122 -onClick => 'return ClearAll (document.detail);'});
124 $buttons = $buttons .
125 submit ({-name => 'action',
126 -value => 'Whitelist',
127 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . ' ' .
128 submit ({-name => 'action',
129 -value => 'Blacklist',
130 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . ' ' .
131 submit ({-name => 'action',
132 -value => 'Nulllist',
133 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . ' ' .
134 submit ({-name => 'action',
136 -onClick => 'return ClearAll (document.detail);'});
139 return $buttons . $next_button;
145 my $current = $next + 1;
147 print div {-align => 'center'}, b (
148 '(' . $current . '-' . $last . ' of ' . $total . ')');
151 -action => 'processaction.cgi',
154 print start_table({-align => 'center',
159 -width => '100%'}) . "\n";
161 my $buttons = MakeButtons $type;
163 print start_div {-class => 'toolbar'};
166 td {-class => 'tablebordertopleft',
167 -valign => 'middle'},
168 td {-class => 'tablebordertopright',
170 -align => 'center'}, $buttons,
174 for my $sender (ReturnSenders(
181 my $msgs = ReturnMessages(
186 # This is for the purposes of supplying a subject line if the mailto address
187 # is clicked on. It's kludgy because we are simply grabbing the subject line
188 # of the first email sent where there may be many emails from this sender.
189 # Still it is often the right subject (or a good enough one)
191 # A little tricky here because of transliteration. If I test for
192 # $msg->[0]{subject} when $msg->[0] is essentially empty I create the hash
193 # making it non empty. Therefore I need to first test if $msgs->[0] exists
198 $heading = $msgs->[0]{subject} if $msgs->[0]{subject};
206 ($onlist, $rule, $seq, $hit_count) = OnWhitelist($sender, $userid, 0);
209 ($onlist, $rule, $seq, $hit_count) = OnBlacklist($sender, 0);
212 ($onlist, $rule, $seq, $hit_count) = OnNulllist($sender, 0);
217 if ($rule =~ /\((\w+):(\d+)\)\s+"(.*)"/) {
220 my $next = $sequence - 1;
225 $rule = "<a href=\"/maps/php/list.php?type=$list&next=$next\">$list:$sequence</a>/$hit_count $rule";
231 start_Tr {-valign => 'middle'};
233 td {-class => 'tableborder'}, small ($next,
234 checkbox {-name => "action$next",
236 hidden ({-name => "email$next",
237 -default => $sender});
239 start_td {-align => 'left'};
241 start_table {-class => 'tablerightdata',
246 -bgcolor => '#d4d0c8'};
249 $heading = "?subject=$heading" if $heading;
251 td {-class => 'tablelabel',
253 -width => '40'}, 'Sender:',
254 td {-class => 'sender',
257 a {-href => "mailto:$sender$heading"}, $sender,
259 -valign => 'middle'},
266 for my $rec (@$msgs) {
267 if ($date eq substr ($rec->{timestamp}, 0, 10)) {
268 $rec->{date} = b font {-color => 'green'}, SQLDatetime2UnixDatetime $rec->{timestamp};
270 $rec->{date} = SQLDatetime2UnixDatetime $rec->{timestamp};
273 $rec->{subject} //= '<Unspecified>';
274 $rec->{subject} = decode_mimewords ($rec->{subject});
275 $rec->{subject} =~ s/\>/>/g;
276 $rec->{subject} =~ s/\</</g;
279 start_table {-class => 'tablerightdata',
286 td {-class => 'msgnbr',
289 -width => '2%'}, $messages++,
290 td {-class => 'tablelabel',
292 -width => '45'}, 'Subject:',
293 td {-class => 'subject',
295 -bgcolor => '#ffffff'},
296 a {-href => "display.cgi?sender=$sender;msg_date=$rec->{timestamp}"}, $rec->{subject},
297 td {-class => 'date',
299 -valign => 'middle'}, $rec->{date},
307 print start_div {-class => 'toolbar'};
310 td {-class => 'tableborderbottomleft',
311 -valign => 'middle'},
312 td {-class => 'tableborderbottomright',
313 -valign => 'middle'},
325 my @scripts = ('ListActions.js');
327 my $heading_date =$date ne '' ? ' on ' . FormatDate ($date, 1) : '';
332 (ucfirst ($type) . ' Report'),
334 $types{$type} [1] . $heading_date,
339 $userid ||= $ENV{USER};
342 NavigationBar($userid);
345 my %options = GetUserOptions($userid);
346 $lines = $options{'Page'};
350 $condition .= "type = '$type'";
352 my $sod = $date . ' 00:00:00';
353 my $eod = $date . ' 23:59:59';
355 $condition .= "type = '$type' and timestamp > '$sod' and timestamp < '$eod'";
360 additional => $condition,
365 $last = $next + $lines < $total ? $next + $lines : $total;
367 if (($next - $lines) > 0) {
368 $prev = $next - $lines;
370 $prev = $next == 0 ? -1 : 0;
375 Footing($table_name);