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 ################################################################################use strict;
17 use MIME::Words qw(:all);
19 $0 = $FindBin::Script;
21 use lib $FindBin::Bin;
27 use CGI qw (:standard *table start_td end_td start_Tr end_Tr start_div end_div);
28 use CGI::Carp 'fatalsToBrowser';
30 my $type = param ('type');
31 my $next = param ('next');
32 my $lines = param ('lines');
33 my $date = param ('date');
42 my $table_name = 'detail';
47 'The following blacklisted users attempted to email you'
51 'Delivered email from the following users'
55 'Discarded messages from the following users'
63 'Automatically detected mail loops from the following users'
67 'The following users have recently registered'
71 'Sent Register reply to the following users'
78 my $prev_button = $prev >= 0 ?
79 a ({-href => "detail.cgi?type=$type;date=$date;next=$prev",
81 }, '<img src=/maps/images/previous.gif border=0 alt=Previous align=middle>') : '';
82 my $next_button = ($next + $lines) < $total ?
83 a {-href => "detail.cgi?type=$type;date=$date;next=" . ($next + $lines),
85 }, '<img src=/maps/images/next.gif border=0 alt=Next align=middle>' : '';
87 my $buttons = $prev_button;
89 if ($type eq 'whitelist') {
91 submit ({-name => 'action',
92 -value => 'Blacklist Marked',
93 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
94 submit ({-name => 'action',
95 -value => 'Nulllist Marked',
96 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
97 submit ({-name => 'action',
98 -value => 'Reset Marks',
99 -onClick => 'return ClearAll (document.detail);'});
100 } elsif ($type eq 'blacklist') {
101 $buttons = $buttons .
102 submit ({-name => 'action',
103 -value => 'Whitelist Marked',
104 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
105 submit ({-name => 'action',
106 -value => 'Nulllist Marked',
107 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
108 submit ({-name => 'action',
109 -value => 'Reset Marks',
110 -onClick => 'return ClearAll (document.detail);'});
111 } elsif ($type eq 'nulllist') {
112 $buttons = $buttons .
113 submit ({-name => 'action',
114 -value => 'Whitelist Marked',
115 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
116 submit ({-name => 'action',
117 -value => 'Blacklist Marked',
118 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
119 submit ({-name => 'action',
120 -value => 'Reset Marks',
121 -onClick => 'return ClearAll (document.detail);'});
123 $buttons = $buttons .
124 submit ({-name => 'action',
125 -value => 'Whitelist Marked',
126 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
127 submit ({-name => 'action',
128 -value => 'Blacklist Marked',
129 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
130 submit ({-name => 'action',
131 -value => 'Nulllist Marked',
132 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
133 submit ({-name => 'action',
134 -value => 'Reset Marks',
135 -onClick => 'return ClearAll (document.detail);'});
138 return $buttons . $next_button;
144 my $current = $next + 1;
146 print div {-align => 'center'}, b (
147 '(' . $current . '-' . $last . ' of ' . $total . ')');
150 -action => 'processaction.cgi',
153 print start_table ({-align => 'center',
158 -width => '100%'}) . "\n";
160 my $buttons = MakeButtons $type;
162 print start_div {-class => 'toolbar'};
165 td {-class => 'tablebordertopleft',
166 -valign => 'middle'},
167 td {-class => 'tablebordertopright',
169 -align => 'center'}, $buttons,
173 foreach my $sender (ReturnSenders $userid, $type, $next, $lines, $date) {
174 my @msgs = ReturnMessages $userid, $sender;
180 ($onlist, $rule) = OnWhitelist $sender;
183 ($onlist, $rule) = OnBlacklist $sender;
186 ($onlist, $rule) = OnNulllist $sender;
191 $rule =~ s/Matching rule: \(//;
194 if ($rule =~ /(\w+):(\d+)/) {
196 my $sequence = $2 - 1;
197 my $link = "<a href=\"/maps/php/list.php?type=$list&next=$sequence\">$list:$2</a>";
199 $rule =~ s/\w+:\d+/$link/;
205 start_Tr {-valign => 'middle'};
207 td {-class => 'tableborder'}, small ($next,
208 checkbox {-name => "action$next",
210 hidden ({-name => "email$next",
211 -default => $sender});
213 start_td {-align => 'left'};
215 start_table {-class => 'tablerightdata',
220 -bgcolor => '#d4d0c8'};
222 td {-class => 'tablelabel',
224 -width => '40'}, 'Sender:',
225 td {-class => 'sender',
228 a {-href => "mailto:$sender?subject=$msgs2[0][0]"}, $sender,
230 -valign => 'middle'},
238 my $msg_date = pop @{$_};
239 my $subject = pop @{$_};
241 if ($date eq substr ($msg_date, 0, 10)) {
242 $msg_date = b font {-color => 'green'}, SQLDatetime2UnixDatetime $msg_date;
244 $msg_date = SQLDatetime2UnixDatetime $msg_date;
247 $subject = $subject eq '' ? '<Unspecified>' : $subject;
248 $subject = decode_mimewords ($subject);
249 $subject =~ s/\>/>/g;
250 $subject =~ s/\</</g;
253 start_table {-class => 'tablerightdata',
258 my $msg_nbr = $messages;
261 td {-class => 'msgnbr',
264 -width => '2%'}, $messages++,
265 td {-class => 'tablelabel',
267 -width => '45'}, 'Subject:',
268 td {-class => 'subject',
270 -bgcolor => '#ffffff'},
271 a {-href => "display.cgi?sender=$sender;msg_nbr=$msg_nbr"}, $subject,
272 td {-class => 'date',
274 -valign => 'middle'}, $msg_date
282 print start_div {-class => 'toolbar'};
285 td {-class => 'tableborderbottomleft',
286 -valign => 'middle'},
287 td {-class => 'tableborderbottomright',
288 -valign => 'middle'},
297 my @scripts = ('ListActions.js');
299 my $heading_date =$date ne '' ? ' on ' . FormatDate ($date) : '';
304 (ucfirst ($type) . ' Report'),
306 $types {$type} [1] . $heading_date,
311 $userid ||= $ENV{USER};
314 NavigationBar $userid;
317 my %options = GetUserOptions $userid;
318 $lines = $options{'Page'};
322 $condition .= "userid = '$userid' and type = '$type'";
324 my $sod = $date . ' 00:00:00';
325 my $eod = $date . ' 23:59:59';
327 $condition .= "userid = '$userid' and type = '$type' "
328 . "and timestamp > '$sod' and timestamp < '$eod' ";
331 $total = MAPSDB::count_distinct ('log', 'sender', $condition);
335 $last = $next + $lines < $total ? $next + $lines : $total;
337 if (($next - $lines) > 0) {
338 $prev = $next - $lines;
340 $prev = $next eq 0 ? -1 : 0;