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 $0 = $FindBin::Script;
22 use lib "$FindBin::Bin/../lib";
28 use CGI qw(:standard *table start_td end_td start_Tr end_Tr start_div end_div);
29 use CGI::Carp 'fatalsToBrowser';
31 my $type = param('type');
32 my $next = param('next');
33 my $lines = param('lines');
34 my $date = param('date');
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($userid, $type, $next, $lines, $date)) {
175 my @msgs = ReturnMessages($userid, $sender);
183 ($onlist, $rule, $seq, $hit_count) = OnWhitelist($sender, $userid, 0);
186 ($onlist, $rule, $seq, $hit_count) = OnBlacklist($sender, 0);
189 ($onlist, $rule, $seq, $hit_count) = OnNulllist($sender, 0);
194 $rule =~ s/Matching rule: \(//;
197 if ($rule =~ /(\w+):(\d+)/) {
199 my $sequence = $2 - 1;
200 my $link = "<a href=\"/maps/php/list.php?type=$list&next=$sequence\">$list:$2</a>/$hit_count";
202 $rule =~ s/\w+:\d+/$link/;
208 start_Tr {-valign => 'middle'};
210 td {-class => 'tableborder'}, small ($next,
211 checkbox {-name => "action$next",
213 hidden ({-name => "email$next",
214 -default => $sender});
216 start_td {-align => 'left'};
218 start_table {-class => 'tablerightdata',
223 -bgcolor => '#d4d0c8'};
226 my $heading = $msgs2[0][0] || '';
227 $heading = "?subject=$heading" if $heading;
229 td {-class => 'tablelabel',
231 -width => '40'}, 'Sender:',
232 td {-class => 'sender',
235 a {-href => "mailto:$sender$heading"}, $sender,
237 -valign => 'middle'},
245 my $msg_date = pop @{$_};
246 my $subject = pop @{$_};
248 if ($date eq substr ($msg_date, 0, 10)) {
249 $msg_date = b font {-color => 'green'}, SQLDatetime2UnixDatetime $msg_date;
251 $msg_date = SQLDatetime2UnixDatetime $msg_date;
254 $subject = $subject eq '' ? '<Unspecified>' : $subject;
255 $subject = decode_mimewords ($subject);
256 $subject =~ s/\>/>/g;
257 $subject =~ s/\</</g;
260 start_table {-class => 'tablerightdata',
265 my $msg_nbr = $messages;
268 td {-class => 'msgnbr',
271 -width => '2%'}, $messages++,
272 td {-class => 'tablelabel',
274 -width => '45'}, 'Subject:',
275 td {-class => 'subject',
277 -bgcolor => '#ffffff'},
278 a {-href => "display.cgi?sender=$sender;msg_nbr=$msg_nbr"}, $subject,
279 td {-class => 'date',
281 -valign => 'middle'}, $msg_date
289 print start_div {-class => 'toolbar'};
292 td {-class => 'tableborderbottomleft',
293 -valign => 'middle'},
294 td {-class => 'tableborderbottomright',
295 -valign => 'middle'},
307 my @scripts = ('ListActions.js');
309 my $heading_date =$date ne '' ? ' on ' . FormatDate ($date) : '';
314 (ucfirst ($type) . ' Report'),
316 $types {$type} [1] . $heading_date,
321 $userid ||= $ENV{USER};
324 NavigationBar($userid);
327 my %options = GetUserOptions($userid);
328 $lines = $options{'Page'};
332 $condition .= "userid = '$userid' and type = '$type'";
334 my $sod = $date . ' 00:00:00';
335 my $eod = $date . ' 23:59:59';
337 $condition .= "userid = '$userid' and type = '$type' "
338 . "and timestamp > '$sod' and timestamp < '$eod' ";
341 $total = count_distinct('log', 'sender', $condition);
345 $last = $next + $lines < $total ? $next + $lines : $total;
347 if (($next - $lines) > 0) {
348 $prev = $next - $lines;
350 $prev = $next == 0 ? -1 : 0;
355 Footing($table_name);